home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #2 / Monster Media No. 2 (Monster Media)(1994).ISO / math / tmpcv10.zip / ACCESSFM.DDF next >
Text File  |  1993-04-28  |  110KB  |  2,892 lines

  1. VERSION 2.00
  2. Begin Form Editor 
  3.    Caption         =   "IconWorks Editor: 1 - [Untitled]"
  4.    ClientHeight    =   4665
  5.    ClientLeft      =   1290
  6.    ClientTop       =   1845
  7.    ClientWidth     =   6165
  8.    ClipControls    =   0   'False
  9.    ForeColor       =   &H00FFFFFF&
  10.    Height          =   5355
  11.    Icon            =   ICONEDIT.FRX:0000
  12.    Left            =   1230
  13.    LinkMode        =   1  'Source
  14.    LinkTopic       =   "Form1"
  15.    ScaleHeight     =   311
  16.    ScaleMode       =   3  'Pixel
  17.    ScaleWidth      =   411
  18.    Top             =   1215
  19.    Width           =   6285
  20.    Begin CommonDialog CMDialog1 
  21.       CancelError     =   -1  'True
  22.       Left            =   15
  23.       Top             =   4140
  24.    End
  25.    Begin PictureBox Pic_ToolPalette 
  26.       AutoSize        =   -1  'True
  27.       BackColor       =   &H00808080&
  28.       BorderStyle     =   0  'None
  29.       DrawMode        =   6  'Invert
  30.       DrawWidth       =   2
  31.       Height          =   3840
  32.       Left            =   0
  33.       Picture         =   ICONEDIT.FRX:0302
  34.       ScaleHeight     =   256
  35.       ScaleMode       =   3  'Pixel
  36.       ScaleWidth      =   32
  37.       TabIndex        =   0
  38.       TabStop         =   0   'False
  39.       Top             =   0
  40.       Visible         =   0   'False
  41.       Width           =   480
  42.    End
  43.    Begin VScrollBar Scrl_Zoom 
  44.       Height          =   3870
  45.       HelpContextID   =   1903
  46.       LargeChange     =   32
  47.       Left            =   480
  48.       Max             =   258
  49.       Min             =   34
  50.       SmallChange     =   32
  51.       TabIndex        =   4
  52.       Tag             =   "9040"
  53.       Top             =   -15
  54.       Value           =   34
  55.       Visible         =   0   'False
  56.       Width           =   270
  57.    End
  58.    Begin PictureBox Pic_Edit 
  59.       BackColor       =   &H000000FF&
  60.       Height          =   3870
  61.       Left            =   735
  62.       ScaleHeight     =   256
  63.       ScaleMode       =   3  'Pixel
  64.       ScaleWidth      =   256
  65.       TabIndex        =   2
  66.       Tag             =   "9000"
  67.       Top             =   -30
  68.       Visible         =   0   'False
  69.       Width           =   3870
  70.       Begin PictureBox Pic_Image 
  71.          AutoRedraw      =   -1  'True
  72.          BackColor       =   &H00000000&
  73.          BorderStyle     =   0  'None
  74.          ForeColor       =   &H00000000&
  75.          Height          =   480
  76.          Left            =   1380
  77.          ScaleHeight     =   32
  78.          ScaleMode       =   3  'Pixel
  79.          ScaleWidth      =   32
  80.          TabIndex        =   5
  81.          TabStop         =   0   'False
  82.          Top             =   945
  83.          Visible         =   0   'False
  84.          Width           =   480
  85.       End
  86.       Begin PictureBox Pic_Mask 
  87.          AutoRedraw      =   -1  'True
  88.          BackColor       =   &H00FFFFFF&
  89.          BorderStyle     =   0  'None
  90.          ForeColor       =   &H00000000&
  91.          Height          =   480
  92.          Left            =   1965
  93.          ScaleHeight     =   32
  94.          ScaleMode       =   3  'Pixel
  95.          ScaleWidth      =   32
  96.          TabIndex        =   6
  97.          TabStop         =   0   'False
  98.          Top             =   945
  99.          Visible         =   0   'False
  100.          Width           =   480
  101.       End
  102.       Begin PictureBox Pic_Grid 
  103.          AutoRedraw      =   -1  'True
  104.          BackColor       =   &H00FFFFFF&
  105.          BorderStyle     =   0  'None
  106.          ForeColor       =   &H00000000&
  107.          Height          =   480
  108.          Left            =   1380
  109.          ScaleHeight     =   32
  110.          ScaleMode       =   3  'Pixel
  111.          ScaleWidth      =   32
  112.          TabIndex        =   19
  113.          Top             =   1515
  114.          Visible         =   0   'False
  115.          Width           =   480
  116.       End
  117.       Begin PictureBox Pic_Work 
  118.          AutoRedraw      =   -1  'True
  119.          AutoSize        =   -1  'True
  120.          BackColor       =   &H00000000&
  121.          BorderStyle     =   0  'None
  122.          FillStyle       =   0  'Solid
  123.          ForeColor       =   &H00000000&
  124.          Height          =   480
  125.          Left            =   1965
  126.          ScaleHeight     =   32
  127.          ScaleMode       =   3  'Pixel
  128.          ScaleWidth      =   32
  129.          TabIndex        =   14
  130.          TabStop         =   0   'False
  131.          Top             =   1515
  132.          Visible         =   0   'False
  133.          Width           =   480
  134.       End
  135.       Begin PictureBox Pic_TempImage 
  136.          AutoRedraw      =   -1  'True
  137.          BackColor       =   &H00000000&
  138.          BorderStyle     =   0  'None
  139.          ForeColor       =   &H00000000&
  140.          Height          =   480
  141.          Left            =   1380
  142.          ScaleHeight     =   32
  143.          ScaleMode       =   3  'Pixel
  144.          ScaleWidth      =   32
  145.          TabIndex        =   15
  146.          Top             =   2085
  147.          Visible         =   0   'False
  148.          Width           =   480
  149.       End
  150.       Begin PictureBox Pic_TempMask 
  151.          AutoRedraw      =   -1  'True
  152.          BackColor       =   &H00FFFFFF&
  153.          BorderStyle     =   0  'None
  154.          Height          =   480
  155.          Left            =   1965
  156.          ScaleHeight     =   32
  157.          ScaleMode       =   3  'Pixel
  158.          ScaleWidth      =   32
  159.          TabIndex        =   16
  160.          Top             =   2085
  161.          Visible         =   0   'False
  162.          Width           =   480
  163.       End
  164.       Begin PictureBox Pic_EditTemp 
  165.          AutoRedraw      =   -1  'True
  166.          BackColor       =   &H00FFFFFF&
  167.          Height          =   480
  168.          Left            =   1680
  169.          ScaleHeight     =   30
  170.          ScaleMode       =   3  'Pixel
  171.          ScaleWidth      =   30
  172.          TabIndex        =   20
  173.          Top             =   2745
  174.          Visible         =   0   'False
  175.          Width           =   480
  176.       End
  177.    End
  178.    Begin PictureBox Pic_StatusArea 
  179.       BackColor       =   &H00C0C0C0&
  180.       FontBold        =   -1  'True
  181.       FontItalic      =   0   'False
  182.       FontName        =   "Courier"
  183.       FontSize        =   9.75
  184.       FontStrikethru  =   0   'False
  185.       FontTransparent =   0   'False
  186.       FontUnderline   =   0   'False
  187.       ForeColor       =   &H00C0C0C0&
  188.       Height          =   4680
  189.       HelpContextID   =   1904
  190.       Left            =   4590
  191.       ScaleHeight     =   310
  192.       ScaleMode       =   3  'Pixel
  193.       ScaleWidth      =   104
  194.       TabIndex        =   7
  195.       TabStop         =   0   'False
  196.       Tag             =   "9010"
  197.       Top             =   -30
  198.       Visible         =   0   'False
  199.       Width           =   1590
  200.       Begin PictureBox Pic_Icons 
  201.          AutoRedraw      =   -1  'True
  202.          BackColor       =   &H00FFFFFF&
  203.          BorderStyle     =   0  'None
  204.          DragIcon        =   ICONEDIT.FRX:137C
  205.          DrawMode        =   4  'Not Copy Pen
  206.          FillStyle       =   0  'Solid
  207.          ForeColor       =   &H00000000&
  208.          Height          =   480
  209.          Index           =   0
  210.          Left            =   210
  211.          Picture         =   ICONEDIT.FRX:167E
  212.          ScaleHeight     =   32
  213.          ScaleMode       =   3  'Pixel
  214.          ScaleWidth      =   32
  215.          TabIndex        =   8
  216.          TabStop         =   0   'False
  217.          Tag             =   "9130"
  218.          Top             =   180
  219.          Width           =   480
  220.       End
  221.       Begin PictureBox Pic_Icons 
  222.          AutoRedraw      =   -1  'True
  223.          BackColor       =   &H00FFFFFF&
  224.          BorderStyle     =   0  'None
  225.          DragIcon        =   ICONEDIT.FRX:1980
  226.          FillStyle       =   0  'Solid
  227.          ForeColor       =   &H00000000&
  228.          Height          =   480
  229.          Index           =   1
  230.          Left            =   885
  231.          Picture         =   ICONEDIT.FRX:1C82
  232.          ScaleHeight     =   32
  233.          ScaleMode       =   3  'Pixel
  234.          ScaleWidth      =   32
  235.          TabIndex        =   9
  236.          TabStop         =   0   'False
  237.          Tag             =   "9130"
  238.          Top             =   180
  239.          Width           =   480
  240.       End
  241.       Begin PictureBox Pic_Icons 
  242.          AutoRedraw      =   -1  'True
  243.          BackColor       =   &H00FFFFFF&
  244.          BorderStyle     =   0  'None
  245.          DragIcon        =   ICONEDIT.FRX:1F84
  246.          FillStyle       =   0  'Solid
  247.          ForeColor       =   &H00000000&
  248.          Height          =   480
  249.          Index           =   2
  250.          Left            =   210
  251.          Picture         =   ICONEDIT.FRX:2286
  252.          ScaleHeight     =   32
  253.          ScaleMode       =   3  'Pixel
  254.          ScaleWidth      =   32
  255.          TabIndex        =   10
  256.          TabStop         =   0   'False
  257.          Tag             =   "9130"
  258.          Top             =   840
  259.          Width           =   480
  260.       End
  261.       Begin PictureBox Pic_Icons 
  262.          AutoRedraw      =   -1  'True
  263.          BackColor       =   &H00FFFFFF&
  264.          BorderStyle     =   0  'None
  265.          DragIcon        =   ICONEDIT.FRX:2588
  266.          FillStyle       =   0  'Solid
  267.          ForeColor       =   &H00000000&
  268.          Height          =   480
  269.          Index           =   3
  270.          Left            =   885
  271.          Picture         =   ICONEDIT.FRX:288A
  272.          ScaleHeight     =   32
  273.          ScaleMode       =   3  'Pixel
  274.          ScaleWidth      =   32
  275.          TabIndex        =   11
  276.          TabStop         =   0   'False
  277.          Tag             =   "9130"
  278.          Top             =   840
  279.          Width           =   480
  280.       End
  281.       Begin PictureBox Pic_Icons 
  282.          AutoRedraw      =   -1  'True
  283.          BackColor       =   &H00FFFFFF&
  284.          BorderStyle     =   0  'None
  285.          DragIcon        =   ICONEDIT.FRX:2B8C
  286.          FillStyle       =   0  'Solid
  287.          ForeColor       =   &H00000000&
  288.          Height          =   480
  289.          Index           =   4
  290.          Left            =   210
  291.          Picture         =   ICONEDIT.FRX:2E8E
  292.          ScaleHeight     =   32
  293.          ScaleMode       =   3  'Pixel
  294.          ScaleWidth      =   32
  295.          TabIndex        =   12
  296.          TabStop         =   0   'False
  297.          Tag             =   "9130"
  298.          Top             =   1500
  299.          Width           =   480
  300.       End
  301.       Begin PictureBox Pic_Icons 
  302.          AutoRedraw      =   -1  'True
  303.          BackColor       =   &H00FFFFFF&
  304.          BorderStyle     =   0  'None
  305.          DragIcon        =   ICONEDIT.FRX:3190
  306.          FillStyle       =   0  'Solid
  307.          ForeColor       =   &H00000000&
  308.          Height          =   480
  309.          Index           =   5
  310.          Left            =   885
  311.          Picture         =   ICONEDIT.FRX:3492
  312.          ScaleHeight     =   32
  313.          ScaleMode       =   3  'Pixel
  314.          ScaleWidth      =   32
  315.          TabIndex        =   13
  316.          TabStop         =   0   'False
  317.          Tag             =   "9130"
  318.          Top             =   1500
  319.          Width           =   480
  320.       End
  321.       Begin PictureBox Pic_Undo 
  322.          BackColor       =   &H00FFFFFF&
  323.          BorderStyle     =   0  'None
  324.          DragIcon        =   ICONEDIT.FRX:3794
  325.          ForeColor       =   &H00FFFFFF&
  326.          Height          =   480
  327.          HelpContextID   =   1902
  328.          Left            =   1035
  329.          Picture         =   ICONEDIT.FRX:3A96
  330.          ScaleHeight     =   32
  331.          ScaleMode       =   3  'Pixel
  332.          ScaleWidth      =   32
  333.          TabIndex        =   3
  334.          TabStop         =   0   'False
  335.          Tag             =   "9150"
  336.          Top             =   2505
  337.          Width           =   480
  338.       End
  339.       Begin OptionButton Opt_Mouse 
  340.          BackColor       =   &H00C0C0C0&
  341.          Height          =   360
  342.          Index           =   0
  343.          Left            =   690
  344.          TabIndex        =   17
  345.          Tag             =   "9160"
  346.          Top             =   3600
  347.          Value           =   -1  'True
  348.          Width           =   195
  349.       End
  350.       Begin OptionButton Opt_Mouse 
  351.          BackColor       =   &H00C0C0C0&
  352.          Height          =   360
  353.          HelpContextID   =   1901
  354.          Index           =   1
  355.          Left            =   690
  356.          TabIndex        =   1
  357.          Tag             =   "9160"
  358.          Top             =   4200
  359.          Width           =   195
  360.       End
  361.    End
  362.    Begin PictureBox Pic_ColorPalette 
  363.       BackColor       =   &H00FFFFFF&
  364.       ForeColor       =   &H00000000&
  365.       Height          =   810
  366.       HelpContextID   =   1905
  367.       Left            =   0
  368.       ScaleHeight     =   52
  369.       ScaleMode       =   3  'Pixel
  370.       ScaleWidth      =   305
  371.       TabIndex        =   18
  372.       TabStop         =   0   'False
  373.       Tag             =   "9030"
  374.       Top             =   3840
  375.       Visible         =   0   'False
  376.       Width           =   4605
  377.    End
  378.    Begin Menu Menu_File 
  379.       Caption         =   "&File"
  380.       HelpContextID   =   1100
  381.       Begin Menu Menu_FileSelection 
  382.          Caption         =   "&New"
  383.          HelpContextID   =   1101
  384.          Index           =   0
  385.       End
  386.       Begin Menu Menu_FileSelection 
  387.          Caption         =   "&Open..."
  388.          HelpContextID   =   1102
  389.          Index           =   1
  390.       End
  391.       Begin Menu Menu_FileSelection 
  392.          Caption         =   "&Save"
  393.          HelpContextID   =   1103
  394.          Index           =   2
  395.          Shortcut        =   +{F12}
  396.       End
  397.       Begin Menu Menu_FileSelection 
  398.          Caption         =   "Save &As..."
  399.          HelpContextID   =   1104
  400.          Index           =   3
  401.          Shortcut        =   {F12}
  402.       End
  403.       Begin Menu Menu_FileSelection 
  404.          Caption         =   "-"
  405.          Index           =   4
  406.       End
  407.       Begin Menu Menu_FileSelection 
  408.          Caption         =   "E&xit"
  409.          HelpContextID   =   1105
  410.          Index           =   5
  411.       End
  412.    End
  413.    Begin Menu Menu_Edit 
  414.       Caption         =   "&Edit"
  415.       HelpContextID   =   1200
  416.       Begin Menu Menu_EditSelection 
  417.          Caption         =   "&Undo"
  418.          HelpContextID   =   1201
  419.          Index           =   0
  420.          Shortcut        =   %{BKSP}
  421.       End
  422.       Begin Menu Menu_EditSelection 
  423.          Caption         =   "-"
  424.          Index           =   1
  425.       End
  426.       Begin Menu Menu_EditSelection 
  427.          Caption         =   "Cu&t"
  428.          HelpContextID   =   1202
  429.          Index           =   2
  430.          Shortcut        =   +{DEL}
  431.       End
  432.       Begin Menu Menu_EditSelection 
  433.          Caption         =   "&Copy"
  434.          HelpContextID   =   1203
  435.          Index           =   3
  436.          Shortcut        =   ^{INSERT}
  437.       End
  438.       Begin Menu Menu_EditSelection 
  439.          Caption         =   "&Paste"
  440.          HelpContextID   =   1204
  441.          Index           =   4
  442.          Shortcut        =   +{INSERT}
  443.       End
  444.       Begin Menu Menu_EditSelection 
  445.          Caption         =   "Paste &Opaque"
  446.          HelpContextID   =   1205
  447.          Index           =   5
  448.          Shortcut        =   ^O
  449.       End
  450.       Begin Menu Menu_EditSelection 
  451.          Caption         =   "&Delete"
  452.          HelpContextID   =   1206
  453.          Index           =   6
  454.          Shortcut        =   {DEL}
  455.       End
  456.       Begin Menu Menu_EditSelection 
  457.          Caption         =   "&Select All"
  458.          HelpContextID   =   1207
  459.          Index           =   7
  460.          Shortcut        =   ^A
  461.       End
  462.       Begin Menu Menu_EditSelection 
  463.          Caption         =   "-"
  464.          Index           =   8
  465.       End
  466.       Begin Menu Menu_EditSelection 
  467.          Caption         =   "Flip &Horizontal"
  468.          HelpContextID   =   1208
  469.          Index           =   9
  470.          Shortcut        =   ^H
  471.       End
  472.       Begin Menu Menu_EditSelection 
  473.          Caption         =   "Flip &Vertical"
  474.          HelpContextID   =   1209
  475.          Index           =   10
  476.          Shortcut        =   ^V
  477.       End
  478.       Begin Menu Menu_EditSelection 
  479.          Caption         =   "-"
  480.          Index           =   11
  481.       End
  482.       Begin Menu Menu_EditSelection 
  483.          Caption         =   "Rotate 90  &Right"
  484.          HelpContextID   =   1210
  485.          Index           =   12
  486.          Shortcut        =   ^R
  487.       End
  488.       Begin Menu Menu_EditSelection 
  489.          Caption         =   "Rotate 90  &Left"
  490.          HelpContextID   =   1211
  491.          Index           =   13
  492.          Shortcut        =   ^L
  493.       End
  494.       Begin Menu Menu_EditSelection 
  495.          Caption         =   "-"
  496.          Index           =   14
  497.       End
  498.       Begin Menu Menu_EditSelection 
  499.          Caption         =   "&Invert"
  500.          HelpContextID   =   1212
  501.          Index           =   15
  502.          Shortcut        =   ^I
  503.       End
  504.    End
  505.    Begin Menu Menu_View 
  506.       Caption         =   "&View"
  507.       HelpContextID   =   1300
  508.       Begin Menu Menu_ViewSelection 
  509.          Caption         =   "&Status Area"
  510.          Checked         =   -1  'True
  511.          HelpContextID   =   1301
  512.          Index           =   0
  513.          Shortcut        =   ^S
  514.       End
  515.       Begin Menu Menu_ViewSelection 
  516.          Caption         =   "&Tool Palette"
  517.          Checked         =   -1  'True
  518.          HelpContextID   =   1302
  519.          Index           =   1
  520.          Shortcut        =   ^T
  521.       End
  522.       Begin Menu Menu_ViewSelection 
  523.          Caption         =   "&Color Palette"
  524.          Checked         =   -1  'True
  525.          HelpContextID   =   1303
  526.          Index           =   2
  527.          Shortcut        =   ^C
  528.       End
  529.       Begin Menu Menu_ViewSelection 
  530.          Caption         =   "&Zooming Scroll bar"
  531.          Checked         =   -1  'True
  532.          HelpContextID   =   1304
  533.          Index           =   3
  534.          Shortcut        =   ^Z
  535.       End
  536.       Begin Menu Menu_ViewSelection 
  537.          Caption         =   "Show &All"
  538.          HelpContextID   =   1305
  539.          Index           =   4
  540.       End
  541.       Begin Menu Menu_ViewSelection 
  542.          Caption         =   "-"
  543.          Index           =   5
  544.       End
  545.       Begin Menu Menu_ViewSelection 
  546.          Caption         =   "&Grid"
  547.          HelpContextID   =   1306
  548.          Index           =   6
  549.          Shortcut        =   ^G
  550.       End
  551.       Begin Menu Menu_ViewSelection 
  552.          Caption         =   "&Line Grid"
  553.          HelpContextID   =   1307
  554.          Index           =   7
  555.       End
  556.       Begin Menu Menu_ViewSelection 
  557.          Caption         =   "&Dotted Grid"
  558.          HelpContextID   =   1308
  559.          Index           =   8
  560.       End
  561.       Begin Menu Menu_ViewSelection 
  562.          Caption         =   "-"
  563.          Index           =   9
  564.       End
  565.       Begin Menu Menu_ViewSelection 
  566.          Caption         =   "Zoom &In"
  567.          HelpContextID   =   1309
  568.          Index           =   10
  569.          Shortcut        =   ^{F11}
  570.       End
  571.       Begin Menu Menu_ViewSelection 
  572.          Caption         =   "Zoom &Out"
  573.          HelpContextID   =   1310
  574.          Index           =   11
  575.          Shortcut        =   ^{F12}
  576.       End
  577.       Begin Menu Menu_ViewSelection 
  578.          Caption         =   "-"
  579.          Index           =   12
  580.       End
  581.       Begin Menu Menu_ViewSelection 
  582.          Caption         =   "&Focus to Editor on Drag&&Drop"
  583.          Checked         =   -1  'True
  584.          HelpContextID   =   1311
  585.          Index           =   13
  586.       End
  587.       Begin Menu Menu_ViewSelection 
  588.          Caption         =   "Display &Border on selected Icon"
  589.          Checked         =   -1  'True
  590.          HelpContextID   =   1312
  591.          Index           =   14
  592.       End
  593.       Begin Menu Menu_ViewSelection 
  594.          Caption         =   "&Pop-up Tools menu on Form Click"
  595.          Checked         =   -1  'True
  596.          HelpContextID   =   1313
  597.          Index           =   15
  598.       End
  599.    End
  600.    Begin Menu Menu_Tools 
  601.       Caption         =   "&Tools"
  602.       HelpContextID   =   1400
  603.       Begin Menu Menu_ToolsSelection 
  604.          Caption         =   "&Select"
  605.          HelpContextID   =   1401
  606.          Index           =   0
  607.       End
  608.       Begin Menu Menu_ToolsSelection 
  609.          Caption         =   "&Paint"
  610.          HelpContextID   =   1402
  611.          Index           =   1
  612.       End
  613.       Begin Menu Menu_ToolsSelection 
  614.          Caption         =   "&Fill"
  615.          HelpContextID   =   1403
  616.          Index           =   2
  617.       End
  618.       Begin Menu Menu_ToolsSelection 
  619.          Caption         =   "&Line"
  620.          HelpContextID   =   1404
  621.          Index           =   3
  622.       End
  623.       Begin Menu Menu_ToolsSelection 
  624.          Caption         =   "&Square"
  625.          HelpContextID   =   1405
  626.          Index           =   4
  627.       End
  628.       Begin Menu Menu_ToolsSelection 
  629.          Caption         =   "Filled S&quare"
  630.          HelpContextID   =   1406
  631.          Index           =   5
  632.       End
  633.       Begin Menu Menu_ToolsSelection 
  634.          Caption         =   "&Circle"
  635.          HelpContextID   =   1407
  636.          Index           =   6
  637.       End
  638.       Begin Menu Menu_ToolsSelection 
  639.          Caption         =   "Filled C&ircle"
  640.          HelpContextID   =   1408
  641.          Index           =   7
  642.       End
  643.    End
  644.    Begin Menu Menu_Icons 
  645.       Caption         =   "&Icons"
  646.       HelpContextID   =   1500
  647.       Begin Menu Menu_IconsSelection 
  648.          Caption         =   "&1 - [Untitled]"
  649.          Index           =   0
  650.       End
  651.       Begin Menu Menu_IconsSelection 
  652.          Caption         =   "&2 - [Untitled]"
  653.          Index           =   1
  654.       End
  655.       Begin Menu Menu_IconsSelection 
  656.          Caption         =   "&3 - [Untitled]"
  657.          Index           =   2
  658.       End
  659.       Begin Menu Menu_IconsSelection 
  660.          Caption         =   "&4 - [Untitled]"
  661.          Index           =   3
  662.       End
  663.       Begin Menu Menu_IconsSelection 
  664.          Caption         =   "&5 - [Untitled]"
  665.          Index           =   4
  666.       End
  667.       Begin Menu Menu_IconsSelection 
  668.          Caption         =   "&6 - [Untitled]"
  669.          Index           =   5
  670.       End
  671.    End
  672.    Begin Menu Menu_Color 
  673.       Caption         =   "&Color"
  674.       HelpContextID   =   1600
  675.       Begin Menu Menu_ColorSelection 
  676.          Caption         =   "&Colors..."
  677.          HelpContextID   =   1601
  678.          Index           =   0
  679.       End
  680.       Begin Menu Menu_ColorSelection 
  681.          Caption         =   "&Default Color Palette"
  682.          Checked         =   -1  'True
  683.          HelpContextID   =   1602
  684.          Index           =   1
  685.       End
  686.       Begin Menu Menu_ColorSelection 
  687.          Caption         =   "S&olid Colors Only"
  688.          HelpContextID   =   1603
  689.          Index           =   2
  690.       End
  691.       Begin Menu Menu_ColorSelection 
  692.          Caption         =   "I&NI File Color Palette"
  693.          HelpContextID   =   1604
  694.          Index           =   3
  695.       End
  696.       Begin Menu Menu_ColorSelection 
  697.          Caption         =   "-"
  698.          Index           =   4
  699.       End
  700.       Begin Menu Menu_ColorSelection 
  701.          Caption         =   "&Save Color Palette to INI file"
  702.          HelpContextID   =   1605
  703.          Index           =   5
  704.       End
  705.       Begin Menu Menu_ColorSelection 
  706.          Caption         =   "-"
  707.          Index           =   6
  708.       End
  709.       Begin Menu Menu_ColorSelection 
  710.          Caption         =   "&Left/Right Colors"
  711.          Checked         =   -1  'True
  712.          HelpContextID   =   1606
  713.          Index           =   7
  714.       End
  715.       Begin Menu Menu_ColorSelection 
  716.          Caption         =   "Screen/&Inverse Colors"
  717.          HelpContextID   =   1607
  718.          Index           =   8
  719.       End
  720.    End
  721.    Begin Menu Menu_Brush 
  722.       Caption         =   "&Brush"
  723.       HelpContextID   =   1700
  724.       Begin Menu Menu_BrushSelection 
  725.          Caption         =   "&Small (1 x 1)"
  726.          Checked         =   -1  'True
  727.          HelpContextID   =   1701
  728.          Index           =   1
  729.       End
  730.       Begin Menu Menu_BrushSelection 
  731.          Caption         =   "&Medium (3 x 3)"
  732.          HelpContextID   =   1702
  733.          Index           =   3
  734.       End
  735.       Begin Menu Menu_BrushSelection 
  736.          Caption         =   "&Large (5 x 5)"
  737.          HelpContextID   =   1703
  738.          Index           =   5
  739.       End
  740.    End
  741.    Begin Menu Menu_Help 
  742.       Caption         =   "&Help"
  743.       Begin Menu Menu_HelpSelection 
  744.          Caption         =   "&Index"
  745.          Index           =   1
  746.       End
  747.       Begin Menu Menu_HelpSelection 
  748.          Caption         =   "&Keyboard"
  749.          Index           =   2
  750.       End
  751.       Begin Menu Menu_HelpSelection 
  752.          Caption         =   "&Commands"
  753.          Index           =   3
  754.       End
  755.       Begin Menu Menu_HelpSelection 
  756.          Caption         =   "&Using Help"
  757.          Index           =   4
  758.       End
  759.       Begin Menu Menu_HelpSelection 
  760.          Caption         =   "-"
  761.          Index           =   5
  762.       End
  763.       Begin Menu Menu_HelpSelection 
  764.          Caption         =   "&About..."
  765.          Index           =   6
  766.       End
  767.    End
  768. End
  769. DefInt A-Z
  770.  
  771. ' When the View.Grid option is selected or deselected, this routine
  772. ' performs the neccessary checking, unchecking of the Grid menu item
  773. ' and Enables or disables the Grid type menu items appropriately,
  774. ' and creates the Grid if selected.
  775. Sub Activate_Grid ()
  776.     Menu_ViewSelection(MID_GRID).Checked = Not Menu_ViewSelection(MID_GRID).Checked
  777.     Menu_ViewSelection(MID_LINE_GRID).Enabled = Menu_ViewSelection(MID_GRID).Checked
  778.     Menu_ViewSelection(MID_DOTTED_GRID).Enabled = Menu_ViewSelection(MID_GRID).Checked
  779.     If Menu_ViewSelection(MID_GRID).Checked Then Create_Grid
  780.     Magnify_Icon 0, 0, 31, 31
  781. End Sub
  782.  
  783. Sub Adjust_Color_Palette ()
  784.     ' Determine if Editor is large enough for ColorPalette
  785.     If (ScaleHeight < (Pic_ColorPalette.Height + 34)) And Menu_ViewSelection(MID_COLOR_PALETTE).Checked Then
  786.         Menu_ViewSelection(MID_COLOR_PALETTE).Checked = False
  787.         Menu_ViewSelection(MID_COLOR_PALETTE).Enabled = False
  788.     Else
  789.         Menu_ViewSelection(MID_COLOR_PALETTE).Enabled = True
  790.         ' Check if the ColorPalette is selected to be displayed.
  791.         If Menu_ViewSelection(MID_COLOR_PALETTE).Checked Then
  792.             NewTop = ScaleHeight - Pic_ColorPalette.Height
  793.             NewWidth = ScaleWidth
  794.             ' Check if the StatusArea is currently displayed, since the StatusArea
  795.             ' affects the width of the ColorPalette.
  796.             If Menu_ViewSelection(MID_STATUS_BAR).Checked Then NewWidth = NewWidth - Pic_StatusArea.Width + 1
  797.             ' Reposition and Resize the ColorPalette.
  798.             Pic_ColorPalette.Move Pic_ColorPalette.Left, NewTop, NewWidth
  799.         End If
  800.     End If
  801. End Sub
  802.  
  803. ' When the Editor is Resized, the the Zoom Scrollbar must be resized,
  804. ' repositioned.  This routine performs the neccessary repositioning
  805. ' for the Zoom Scrollbar.
  806. '
  807. Sub Adjust_ScrollBar ()
  808.     If Menu_ViewSelection(MID_TOOL_PALETTE).Checked Then NewLeft = Pic_ToolPalette.Width Else NewLeft = -1
  809.     NewHeight = ScaleHeight + 2 + Menu_ViewSelection(MID_COLOR_PALETTE).Checked * Pic_ColorPalette.Height
  810.     NewMax = ScaleWidth - (NewLeft - Menu_ViewSelection(MID_ZOOM_SCROLLBAR).Checked * Scrl_Zoom.Width) + 3 + (Menu_ViewSelection(MID_STATUS_BAR).Checked * Pic_StatusArea.Width)
  811.     ' Set the new Max value to the smaller of the NewHeight and the NewMax value.
  812.     If NewMax > NewHeight Then NewMax = NewHeight
  813.     ' We must adjust the New Max value obtained above so it is a multiple of 32.
  814.     While (NewMax - 2) Mod 32
  815.         NewMax = NewMax - 1
  816.     Wend
  817.     Scrl_Zoom.Move NewLeft, Scrl_Zoom.Top, Scrl_Zoom.Width, NewHeight
  818.     Scrl_Zoom.Max = NewMax
  819.     ' Determine if current size of the Editing area is larger than the new maximum size.
  820.     If Pic_Edit.Height > Scrl_Zoom.Max Then
  821.         Scrl_Zoom.Value = Scrl_Zoom.Max
  822.     Else
  823.         Scrl_Zoom_Change
  824.     End If
  825. End Sub
  826.  
  827. ' When the Editor is Resized, the the StatusArea must be resized, and hidden if necessary
  828. Sub Adjust_Status_Bar ()
  829.     ' Determine if Editor is large enough for StatusArea
  830.     If ((ScaleHeight < (Pic_Icons(5).Top + Pic_Icons(5).Height + HIGHLIGHT)) Or (ScaleWidth < 2 * Pic_StatusArea.Width)) And Menu_ViewSelection(MID_STATUS_BAR).Checked Then
  831.         Menu_ViewSelection(MID_STATUS_BAR).Checked = False
  832.         Menu_ViewSelection(MID_STATUS_BAR).Enabled = False
  833.     Else
  834.         Menu_ViewSelection(MID_STATUS_BAR).Enabled = True
  835.         If Menu_ViewSelection(MID_STATUS_BAR).Checked Then
  836.             OldHeight = Pic_StatusArea.Height
  837.             Pic_StatusArea.Move ScaleWidth - Pic_StatusArea.Width + 1, Pic_StatusArea.Top, Pic_StatusArea.Width, ScaleHeight + 2
  838.             NewTop = Pic_StatusArea.ScaleHeight - 4.25 * Opt_Mouse(0).Height
  839.             Opt_Mouse(0).Top = NewTop + 1.25 * Opt_Mouse(0).Height
  840.             Opt_Mouse(1).Top = NewTop + 3 * Opt_Mouse(0).Height
  841.             Visibility = NewTop >= (Pic_Icons(5).Top + Pic_Icons(5).Height + 2 * HIGHLIGHT + 4)
  842.             Opt_Mouse(0).Visible = Visibility
  843.             Opt_Mouse(1).Visible = Visibility
  844.             ' Determine if there is room to display the Undo Icon
  845.             If Opt_Mouse(0).Visible Then
  846.                 Pic_Undo.Visible = NewTop >= (Pic_Undo.Top + Pic_Undo.Height)
  847.             Else
  848.                 Pic_Undo.Visible = (Pic_Undo.Top + Pic_Undo.Height) <= Pic_StatusArea.ScaleHeight
  849.             End If
  850.             ' We only want to force it to repaint if its size has changed
  851.             If OldHeight <> Pic_StatusArea.Height Then Pic_StatusArea.Refresh
  852.         End If
  853.     End If
  854.  
  855. End Sub
  856.  
  857. ' When the Editor is Resized, the the ToolPalette may need to be hidden.
  858. Sub Adjust_Tool_Palette ()
  859.     If ((ScaleHeight < (Pic_ToolPalette.Height + Pic_ColorPalette.Height)) And Menu_ViewSelection(MID_COLOR_PALETTE).Checked) Or ((ScaleHeight < Pic_ToolPalette.Height) And (Not Menu_ViewSelection(MID_COLOR_PALETTE).Checked)) Then
  860.         Menu_ViewSelection(MID_TOOL_PALETTE).Checked = False
  861.         Menu_ViewSelection(MID_TOOL_PALETTE).Enabled = False
  862.     Else
  863.         Menu_ViewSelection(MID_TOOL_PALETTE).Enabled = True
  864.     End If
  865. End Sub
  866.  
  867. ' To make magnified pixels appear more like single pixels when working
  868. ' with the various tools, this routine is used to adjust the actual pixel
  869. ' clicked to the Center or to the Edge of the selected magnified pixel.
  870. Sub Adjust_X_and_Y (x As Single, Y As Single, NewX, NewY, Adjustment)
  871.     Select Case Adjustment
  872.         Case TO_CENTER
  873.             NewX = (x \ PixelSize) * PixelSize + (PixelSize \ 2)
  874.             NewY = (Y \ PixelSize) * PixelSize + (PixelSize \ 2)
  875.         Case TO_EDGE
  876.             Xpix = x \ PixelSize
  877.             Ypix = Y \ PixelSize
  878.             If (x Mod PixelSize) >= (PixelSize / 2) Then Xpix = Xpix + 1
  879.             If (Y Mod PixelSize) >= (PixelSize / 2) Then Ypix = Ypix + 1
  880.             NewX = Xpix * PixelSize
  881.             NewY = Ypix * PixelSize
  882.     End Select
  883. End Sub
  884.  
  885. ' This routine is called when ever the selection is to be comitted to the Icon.
  886. Sub Commit_Selection (ResetFlags)
  887.     ' Erase the Rectangle highlighting the selection
  888.     If Selecting Then Draw_Selection_Rectangle
  889.     Scale_Region True, X1, Y1, X2, Y2, True
  890.     If Menu_ViewSelection(MID_GRID).Checked Then Display_Grid (Pic_Edit.hDC), X1, Y1, X2, Y2
  891.     W = X2 - X1
  892.     H = Y2 - Y1
  893.     If Opaque Then
  894.         ' An exact copy of Mask and Image of the Selection are copied
  895.         R = BitBlt(Pic_Image.hDC, X1, Y1, W, H, Pic_TempImage.hDC, X1SelectFrom, Y1SelectFrom, SRCCOPY)
  896.         R = BitBlt(Pic_Mask.hDC, X1, Y1, W, H, Pic_TempMask.hDC, X1SelectFrom, Y1SelectFrom, SRCCOPY)
  897.     Else
  898.         ' Only the Foreground colors are copied.
  899.         R = BitBlt(Pic_Image.hDC, X1, Y1, W, H, Pic_TempMask.hDC, X1SelectFrom, Y1SelectFrom, SRCAND)
  900.         R = BitBlt(Pic_Image.hDC, X1, Y1, W, H, Pic_TempImage.hDC, X1SelectFrom, Y1SelectFrom, SRCINVERT)
  901.         R = BitBlt(Pic_Mask.hDC, X1, Y1, W, H, Pic_TempMask.hDC, X1SelectFrom, Y1SelectFrom, SRCAND)
  902.     End If
  903.     If ResetFlags Then
  904.         Selecting = False
  905.         MovingSelection = False
  906.     End If
  907.     ' Replace the Icons current Mask and Image bitmaps with the new ones.
  908.     Update_Icon Pic_Icons(CurrentIcon)
  909. End Sub
  910.  
  911. ' This routine is called either in response to an Edit.Cut or Edit.Copy
  912. Sub Copy_Selection_To_ClipBoard (X1, Y1, X2, Y2)
  913.     Scale_Region True, X1, Y1, X2, Y2, True
  914.     Pic_Work.Picture = LoadPicture()
  915.     Pic_Work.Move Pic_Work.Left, Pic_Work.Top, X2 - X1, Y2 - Y1
  916.     R = BitBlt(Pic_Work.hDC, 0, 0, Pic_Work.Width, Pic_Work.Height, Pic_Icons(CurrentIcon).hDC, X1, Y1, SRCCOPY)
  917.     Clipboard.Clear
  918.     Clipboard.SetData Pic_Work.Image
  919. End Sub
  920.  
  921. ' The Grid is drawn on a separate Picture control with a White BackGround and
  922. ' Black Foreground, and is only drawn once.  When a piece of the
  923. ' grid is to be redisplayed, the part of the Grid that corresponds
  924. ' to the area of the Icon that needs to be updated is BitBlt'd
  925. ' from the Picture of the Grid over the top of the Displayed Icon,
  926. ' Using the SCRAND raster operation.
  927. Sub Create_Grid ()
  928.     Pic_Grid.Move 0, 0, Scrl_Zoom.Value, Scrl_Zoom.Value
  929.     Pic_Grid.Cls
  930.     If Menu_ViewSelection(MID_LINE_GRID).Checked Then
  931.         For I = 1 To 31
  932.             Pic_Grid.Line (0, I * PixelSize)-(Pic_Grid.ScaleWidth, I * PixelSize)
  933.             Pic_Grid.Line (I * PixelSize, 0)-(I * PixelSize, Pic_Grid.ScaleHeight)
  934.         Next I
  935.     Else
  936.         For Y = 0 To 31
  937.             For x = 0 To 31
  938.                 Pic_Grid.PSet ((x * PixelSize) + (PixelSize \ 2), (Y * PixelSize) + (PixelSize \ 2))
  939.             Next x
  940.         Next Y
  941.     End If
  942. End Sub
  943.  
  944. ' This routine is called in response to an Edit.Cut, Copy, or
  945. ' Delete menu selection.
  946. Sub Cut_Copy_Or_Delete_Selection (Index)
  947.     If Index = MID_DELETE Then
  948.         Scale_Region True, X1, Y1, X2, Y2, True
  949.     Else
  950.         Copy_Selection_To_ClipBoard X1, Y1, X2, Y2
  951.     End If
  952.     If Index <> MID_COPY Then
  953.         Delete_Selection_From_Icon
  954.         Selecting = False
  955.         Magnify_Icon X1, Y1, X2, Y2
  956.     End If
  957. End Sub
  958.  
  959. ' This routine is called either in response to an Edit.Cut or Edit.Delete
  960. Sub Delete_Selection_From_Icon ()
  961.     Scale_Region True, X1, Y1, X2, Y2, True
  962.     Pic_Image.Line (X1, Y1)-(X2 - 1, Y2 - 1), BLACK, BF
  963.     Pic_Mask.Line (X1, Y1)-(X2 - 1, Y2 - 1), WHITE, BF
  964.     Update_Icon Pic_Icons(CurrentIcon)
  965. End Sub
  966.  
  967. ' This routine is called to display the mouse coordinates.  The
  968. ' coordinates are that of the magnified pixels, not the screen
  969. ' coordinates, thus, regardless of the magnification of the Icon,
  970. ' the coordinates will all range from 0-31.
  971. Sub Display_Mouse_Coordinates (Xpix, Ypix)
  972.     If (Xpix >= 0) And (Xpix <= 31) Then
  973.         Pic_StatusArea.CurrentX = Pic_StatusArea.ScaleWidth * .25
  974.         Pic_StatusArea.Print Space$(Abs(Xpix < 10)) + Format$(Xpix);
  975.     End If
  976.     If (Ypix >= 0) And (Ypix <= 31) Then
  977.         Pic_StatusArea.CurrentX = Pic_StatusArea.ScaleWidth * .75
  978.         Pic_StatusArea.Print Space$(Abs(Ypix < 10)) + Format$(Ypix);
  979.     End If
  980. End Sub
  981.  
  982. ' The routine is called to display
  983. ' the Line or Box for the above tools when requested.
  984. Sub Draw_Line_Or_Box ()
  985.     If CurrentTool = TID_LINE Then
  986.         Pic_Edit.Line (X1Region, Y1Region)-(X2Region, Y2Region)
  987.     Else
  988.         Pic_Edit.Line (X1Region, Y1Region)-(X2Region, Y2Region), , B
  989.     End If
  990. End Sub
  991.  
  992. ' Since Windows INItialization files only allow the writing string information,
  993. ' the Color Palette color values are stored in 3 strings, 1 for each row of the
  994. ' color palette.  This routine is called to extract these color values from
  995. ' the strings and assign them to the Long Integer Color array.
  996. Sub Extract_Colors_From_String (ColorString As String, FirstColor, RefreshPalette)
  997.     N = 1
  998.     For C = FirstColor To FirstColor + 15
  999.         I = InStr(N, ColorString, " ")
  1000.         If I = 0 Then I = Len(ColorString) + 1
  1001.         Colors(C) = Val(Mid$(ColorString, N, I - N))
  1002.         N = I + 1
  1003.     Next C
  1004.     If RefreshPalette Then
  1005.         Display_Color_Palette Pic_ColorPalette
  1006.         If ColorPaletteLoaded Then Display_Color_Palette ColorPalette.Pic_ColorPalette
  1007.     End If
  1008. End Sub
  1009.  
  1010. ' This routine performs a Surface Flood fill of the selected area
  1011. ' within the Icon when the Fill tool is in use.  The Mask color
  1012. ' of all pixels that are different is then compare to the Mask
  1013. ' color of the original starting Pixel.  If the Mask colors are the
  1014. ' same the Pixel should be changed, otherwise it is unchanged.
  1015. Sub Fill_Tool_MouseUp (x As Single, Y As Single, X2, Y2)
  1016. Dim MaskColor As Long, NewPixelColor As Long
  1017.     If (Abs(x) >= 0) And (Abs(x) <= Pic_Edit.ScaleWidth) And (Abs(Y) >= 0) And (Abs(Y) <= Pic_Edit.ScaleHeight) Then
  1018.         Screen.MousePointer = HOURGLASS
  1019.         Xpixel = x \ PixelSize
  1020.         Ypixel = Y \ PixelSize
  1021.         MaskColor = Pic_Mask.Point(Xpixel, Ypixel)
  1022.         Pic_Work.FillColor = Pic_Edit.ForeColor
  1023.         Pic_Work.Picture = Pic_Icons(CurrentIcon).Image
  1024.         R = ExtFloodFill(Pic_Work.hDC, Xpixel, Ypixel, Pic_Icons(CurrentIcon).Point(Xpixel, Ypixel), FLOODFILLSURFACE)
  1025.         For Ypix = 0 To 31
  1026.             For Xpix = 0 To 31
  1027.                 NewPixelColor = Pic_Work.Point(Xpix, Ypix)
  1028.                 If (Pic_Icons(CurrentIcon).Point(Xpix, Ypix) <> NewPixelColor) And (Pic_Mask.Point(Xpix, Ypix) = MaskColor) Then
  1029.                     '
  1030.                     ' Pixel was changed by the FloodFill and its Mask matched that of the
  1031.                     ' starting Pixel, so we make the change on the Icons Image and Mask
  1032.                     '
  1033.                     If Opt_Mouse(SCREEN_COLORS).Value Then NewPixelColor = Pic_Image.ForeColor
  1034.                     Pic_Image.PSet (Xpix, Ypix), NewPixelColor
  1035.                     Pic_Mask.PSet (Xpix, Ypix)
  1036.                 End If
  1037.             Next Xpix
  1038.         Next Ypix
  1039.         Screen.MousePointer = DEFAULT
  1040.         X2 = 31
  1041.         Y2 = 31
  1042.     End If
  1043. End Sub
  1044.  
  1045. ' This routine Flips (Mirrors) the current Selection either
  1046. ' Horizontally or Vertically.   The Windows API StretchBlt()
  1047. ' routine is used to perform the Flip operation.
  1048. Sub Flip_Selection (Index)
  1049.     W = X2SelectFrom - X1SelectFrom
  1050.     H = Y2SelectFrom - Y1SelectFrom
  1051.     If Index = MID_FLIP_HORIZONTAL Then
  1052.         DestX = X2SelectFrom - 1
  1053.         DestY = Y1SelectFrom
  1054.         DestWidth = -W
  1055.         DestHeight = H
  1056.     Else
  1057.         DestX = X1SelectFrom
  1058.         DestY = Y2SelectFrom - 1
  1059.         DestWidth = W
  1060.         DestHeight = -H
  1061.     End If
  1062.     R = StretchBlt(Pic_TempImage.hDC, DestX, DestY, DestWidth, DestHeight, Pic_TempImage.hDC, X1SelectFrom, Y1SelectFrom, W, H, SRCCOPY)
  1063.     R = StretchBlt(Pic_TempMask.hDC, DestX, DestY, DestWidth, DestHeight, Pic_TempMask.hDC, X1SelectFrom, Y1SelectFrom, W, H, SRCCOPY)
  1064.     R = StretchBlt(Pic_Work.hDC, DestX, DestY, DestWidth, DestHeight, Pic_Work.hDC, X1SelectFrom, Y1SelectFrom, W, H, SRCCOPY)
  1065.     Scale_Region True, X1, Y1, X2, Y2, False
  1066.     If Not MovingSelection Then Commit_Selection False
  1067.     Magnify_Icon X1, Y1, X2, Y2
  1068. End Sub
  1069.  
  1070. Sub Form_Load ()
  1071.  
  1072.     ' Determine color mode and set Icons Image bitmap size accordingly
  1073.     ' This value, ImageSize, is used within the routines Update_Icon and
  1074.     ' Extract_Image_And_Mask within ICONWRKS.BAS
  1075.     '
  1076.     If GetDeviceCaps(hDC, BITSPIXEL) = 8 Then
  1077.         ImageSize = 1024 'bytes
  1078.     Else
  1079.         ImageSize = 512  'bytes
  1080.     End If
  1081.  
  1082.     ' Depending on the Video mode and video driver being used for Windows,
  1083.     ' the controls on a form might not be the same dimensions when loaded
  1084.     ' under differenct resolutions.  Since the Editor is based on a
  1085.     ' 32x32 pixel Icon, the Picture controls that are used to manipulate
  1086.     ' the icons must be set at runtime to 32x32.
  1087.     '
  1088.     ' Position and size Icon within StatusArea
  1089.     '
  1090.     Edge = (Pic_StatusArea.ScaleWidth - 64) \ 3
  1091.     For Y = 0 To 2
  1092.         For x = 0 To 1
  1093.             Pic_Icons(x + Y * 2).Move Edge + x * (32 + Edge), Edge + Y * (32 + Edge), 32, 32
  1094.         Next x
  1095.     Next Y
  1096.  
  1097.     Pic_Mask.Move 0, 0, 32, 32
  1098.     Pic_Image.Move 0, 0, 32, 32
  1099.     Pic_TempMask.Move 0, 0, 32, 32
  1100.     Pic_TempImage.Move 0, 0, 32, 32
  1101.     Pic_Work.Move 0, 0, 32, 32
  1102.     Pic_Grid.Move 0, 0, 32, 32
  1103.     Pic_ToolPalette.Move 0, 0, 32, 256
  1104.     Pic_Undo.Move Pic_StatusArea.ScaleWidth - 34, (Editor.Pic_Icons(5).Top + Editor.Pic_Icons(5).Height + 2.5 * HIGHLIGHT), 32, 32
  1105.     
  1106.     Get_INI_File_Settings
  1107.  
  1108.     ' Adjust size of Editor appropriately for the Video mode.
  1109.     '
  1110.     
  1111.     If Screen.Height = EGA_HEIGHT Then
  1112.         '
  1113.         ' EGA mode
  1114.         '
  1115.         
  1116.         NewWidth = Width
  1117.         NewHeight = Screen.Height
  1118.         NewTop = 0
  1119.     Else
  1120.         ' VGA or Better
  1121.         '
  1122.         NewWidth = Screen.Width * .75
  1123.         NewHeight = Screen.Height * .75
  1124.         NewTop = (Screen.Height - NewHeight) \ 2
  1125.     End If
  1126.     Move (Screen.Width - NewWidth) \ 2, NewTop, NewWidth, NewHeight
  1127.  
  1128.     ' Icon is initially displayed at full maginification
  1129.     '
  1130.     Scrl_Zoom.Value = Scrl_Zoom.Max
  1131.  
  1132.     ' Create Monochrome Hdc and Bitmap to be used when replace the
  1133.     ' Icons Monochrome Mask.
  1134.     '
  1135.     MonoHdc = CreateCompatibleDC(hDC)
  1136.     MonoHbm = CreateCompatibleBitmap(MonoHdc, 32, 32)
  1137.     OldObject = SelectObject(MonoHdc, MonoHbm)
  1138.  
  1139.     ' The BackColor of the Editing area picture control, Pic_Edit,
  1140.     ' is set to Red at design time just so the picture controls contained
  1141.     ' within it are visible at design time.
  1142.     '
  1143.     Pic_Edit.BackColor = WHITE
  1144.  
  1145.     ' Select initial tool and brushsize
  1146.     '
  1147.     CurrentTool = TID_PAINT
  1148.     BrushSize = 1
  1149.   
  1150.     ' Initialize Default Mouse Colors
  1151.     '
  1152.     MouseColors(0) = BLACK  'Left
  1153.     MouseColors(1) = RED    'Right
  1154.     MouseColors(2) = WHITE  'Screen
  1155.     MouseColors(3) = BLACK  'Inverse
  1156.  
  1157.     ' Add Accelerators that are not available from the Menu Design window
  1158.     ' to the appropriate menu items.
  1159.     '
  1160.     Menu_FileSelection(MID_EXIT).Caption = "E&xit" + A_TAB + "Alt+F4"
  1161.     'Menu_EditSelection(MID_UNDO).Caption = "&Undo" + A_TAB + "Alt+Bksp"
  1162.     'Menu_EditSelection(MID_CUT).Caption = "Cu&t" + A_TAB + "Shift+Del"
  1163.     'Menu_EditSelection(MID_COPY).Caption = "&Copy" + A_TAB + "Ctrl+Ins"
  1164.     'Menu_EditSelection(MID_PASTE).Caption = "&Paste" + A_TAB + "Shift+Ins"
  1165.     'Menu_EditSelection(MID_PASTE_OPAQUE).Caption = "Paste &Opaque" + A_TAB + "Ctrl+Shift+Ins"
  1166.     'Menu_EditSelection(MID_DELETE).Caption = "&Delete" + A_TAB + "Del"
  1167.  
  1168.     ' Initialize all 6 Icons filename to UNTITLED, so a File.Save opertion
  1169.     ' will react just like a File.Save As, the first time.
  1170.     '
  1171.     For I = 0 To 5
  1172.       IconInfo(I).FileName = UNTITLED
  1173.     Next I
  1174.     
  1175.     EditorLoaded = True
  1176.  
  1177. End Sub
  1178.  
  1179. ' Just for an added convience when selecting tools, Clicking anywhere
  1180. ' on the Editor that is not covered by another control, will display
  1181. ' the Tools menu as a pupup menu at that location.
  1182. '
  1183. Sub Form_MouseUp (Button As Integer, Shift As Integer, x As Single, Y As Single)
  1184.  
  1185.     ' Menu is displayed on if the left button is used.
  1186.     '
  1187.     If (Button = RIGHT_BUTTON) And Menu_ViewSelection(MID_POPUP_MENU).Checked Then
  1188.         '
  1189.         ' The X and Y coordintes passed to the TrackPopupMenu() API routine
  1190.         ' are Screen coordinates in pixels, not Form coordinates, so, the
  1191.         ' X and Y coordinates of the Mouse must be adjusted, taking into
  1192.         ' account the position of the form.  And for a little more added
  1193.         ' convience, another adjustment is made so when the menu pops up,
  1194.         ' the mouse poiner is directly over the currently selected tool.
  1195.         '
  1196.         InPixels = ScaleWidth
  1197.         ScaleMode = TWIPS
  1198.         TwipsToPixels = ScaleWidth \ InPixels
  1199.         Borders = (Width - ScaleWidth)
  1200.         TitleBarAndMenu = (Height - ScaleHeight - Borders)
  1201.         IX = x + (Left \ TwipsToPixels)
  1202.         IY = Y + (Top + TitleBarAndMenu - CurrentTool * (TitleBarAndMenu \ 2)) \ TwipsToPixels
  1203.         ScaleMode = pixels
  1204.         Menu_ToolsSelection(CurrentTool).Checked = True
  1205.         R = TrackPopupMenu(GetSubMenu(GetMenu(hwnd), 3), 0, IX, IY, 0, hwnd, 0)
  1206.     End If
  1207.  
  1208. End Sub
  1209.  
  1210. ' Resizing of the Editor can, depending on the new size, force any
  1211. ' of the palettes to be hidden, so all major controls must be
  1212. ' resized, repositioned and possibly hidden in reponse to resizing
  1213. ' the Editor.
  1214. '
  1215. Sub Form_Resize ()
  1216. Static LastWindowState
  1217.  
  1218.     ' Nothing is done if the Editor is minimized.
  1219.     '
  1220.     If WindowState = MINIMIZED Then
  1221.         '
  1222.         ' Hide ColorPalette since it should not be visible while the
  1223.         ' Editor is Minimized.
  1224.         '
  1225.         If ColorPaletteLoaded Then ColorPalette.Hide
  1226.  
  1227.     ElseIf ScaleHeight >= 34 Then
  1228.         '
  1229.         ' Hide the Editing area while resizing other controls
  1230.         ' to prevent uneccessary repaints.
  1231.         '
  1232.         Pic_Edit.Visible = False
  1233.  
  1234.         ' Adjust all major controls
  1235.         '
  1236.         Adjust_Status_Bar
  1237.         Adjust_Tool_Palette
  1238.         Adjust_Color_Palette
  1239.         Adjust_ScrollBar
  1240.     
  1241.         ' Hide or Show the major controls, based on their corresponding View
  1242.         ' menu item Checked value, which was set within the above *Adjust*
  1243.         ' routines.
  1244.         '
  1245.         Pic_ColorPalette.Visible = Menu_ViewSelection(MID_COLOR_PALETTE).Checked
  1246.         Pic_ToolPalette.Visible = Menu_ViewSelection(MID_TOOL_PALETTE).Checked
  1247.         Pic_StatusArea.Visible = Menu_ViewSelection(MID_STATUS_BAR).Checked
  1248.         Scrl_Zoom.Visible = Menu_ViewSelection(MID_ZOOM_SCROLLBAR).Checked
  1249.         
  1250.         If (LastWindowState = MINIMIZED) And ColorPaletteLoaded Then ColorPalette.Show
  1251.  
  1252.     End If
  1253.  
  1254.     LastWindowState = WindowState
  1255.  
  1256. End Sub
  1257.  
  1258. ' Editor is being terminated
  1259. '
  1260. Sub Form_Unload (Cancel As Integer)
  1261.     
  1262.     ' Check fo any icons that have been modified since they
  1263.     ' were last saved.
  1264.     '
  1265.     Text = ""
  1266.     For I = 0 To 5
  1267.         If IconInfo(I).Changed Then Text = Text + "Icon #" + Right$(Menu_IconsSelection(I).Caption, Len(Menu_IconsSelection(I).Caption) - 1) + CRLF
  1268.     Next I
  1269.     
  1270.     If Text <> "" Then
  1271.         '
  1272.         ' One or more icons were changed, so prompt user.
  1273.         '
  1274.         Text = Text + CRLF + "The icons listed have not been saved since their last modification.  Quit anyway?"
  1275.         Cancel = MsgBox(Text, 36, "ICONS HAVE CHANGED") = MBNO
  1276.     End If
  1277.  
  1278.     If Not Cancel Then
  1279.         '
  1280.         ' User wants to terminate Editor, so clean up.
  1281.         '
  1282.         EditorLoaded = False
  1283.         Unload ColorPalette
  1284.         R = DeleteDC(MonoHdc)
  1285.         R = DeleteObject(MonoHbm)
  1286.         R = WinHelp(hwnd, dummy$, HELP_QUIT, 0)
  1287.         Save_Settings_To_INI_File
  1288.         '
  1289.         ' If Editor was started up first (Null command line or anything other than
  1290.         ' "v" or "V") then we treat it as the main Form.  So, if the Viewer is loaded,
  1291.         ' we should as the user if the Viewer should also be terminated.
  1292.         '
  1293.         If (MainForm = ICONWORKS_EDITOR) And ViewerLoaded Then
  1294.             '
  1295.             ' Editor was started first and the Viewer is loaded so ask the user
  1296.             ' if the Viewer should also be terminated.
  1297.             '
  1298.             Text = "Terminate Viewer also?"
  1299.             If MsgBox(Text, 36, "IconWorks") = MBYES Then Unload Viewer
  1300.             MainForm = ICONWORKS_VIEWER
  1301.         End If
  1302.     End If
  1303.  
  1304. End Sub
  1305.  
  1306. ' In response to a MouseDown event in the Edit area, the first thing
  1307. ' that must be done is deterine what color to use when drawing the object.
  1308. Sub Get_Current_Colors (Button As Integer)
  1309.     ' Determine which of the 4 currently selected colors to use, and
  1310.     ' assign to the Edit area's foreground color.
  1311.     Index = Opt_Mouse(SCREEN_COLORS).Value * (-2) + Button - 1
  1312.     Pic_Edit.ForeColor = MouseColors(Index)
  1313.     ' If using the Paint tool, we must use the Neaest Solid color to the selected color.
  1314.     If CurrentTool = TID_PAINT Then Pic_Edit.ForeColor = GetNearestColor(hDC, Pic_Edit.ForeColor)
  1315.     If Opt_Mouse(MOUSE_COLORS).Value Then
  1316.         Pic_Image.ForeColor = Pic_Edit.ForeColor
  1317.     Else
  1318.         Pic_Image.ForeColor = (Button = RIGHT_BUTTON) And WHITE
  1319.     End If
  1320.     Pic_Mask.ForeColor = Opt_Mouse(SCREEN_COLORS).Value And WHITE
  1321.     Pic_Image.FillColor = Pic_Image.ForeColor
  1322.     Pic_Mask.FillColor = Pic_Mask.ForeColor
  1323.     Pic_Edit.FillColor = Pic_Edit.ForeColor
  1324. End Sub
  1325.  
  1326. ' This routine is called to read the color value strings from
  1327. ' the IconWrks.INI file, and then have The values extracted
  1328. Sub Get_INI_File_Colors ()
  1329.     ColorString = Space$(144)
  1330.     R = GetPrivateProfileString(APP_NAME, KEY_COLOR + "1", DEFAULT_COLORS_ROW1, ColorString, Len(ColorString), INI_FILENAME)
  1331.     Extract_Colors_From_String ColorString, 0, False
  1332.     R = GetPrivateProfileString(APP_NAME, KEY_COLOR + "2", DEFAULT_COLORS_ROW2, ColorString, Len(ColorString), INI_FILENAME)
  1333.     Extract_Colors_From_String ColorString, 16, False
  1334.     R = GetPrivateProfileString(APP_NAME, KEY_COLOR + "3", DEFAULT_COLORS_ROW3, ColorString, Len(ColorString), INI_FILENAME)
  1335.     Extract_Colors_From_String ColorString, 32, True
  1336. End Sub
  1337.  
  1338. ' This routine is called only once, which is at load time to obtain
  1339. ' all settings saved to the IconWrks.INI file.
  1340. Sub Get_INI_File_Settings ()
  1341.     Menu_ViewSelection(MID_STATUS_BAR).Checked = -GetPrivateProfileInt(APP_NAME, KEY_STATUS_BAR, 1, INI_FILENAME)
  1342.     Menu_ViewSelection(MID_TOOL_PALETTE).Checked = -GetPrivateProfileInt(APP_NAME, KEY_TOOL_PALETTE, 1, INI_FILENAME)
  1343.     Menu_ViewSelection(MID_COLOR_PALETTE).Checked = -GetPrivateProfileInt(APP_NAME, KEY_COLOR_PALETTE, 1, INI_FILENAME)
  1344.     Menu_ViewSelection(MID_ZOOM_SCROLLBAR).Checked = -GetPrivateProfileInt(APP_NAME, KEY_ZOOM_SCROLLBAR, 1, INI_FILENAME)
  1345.     Menu_ViewSelection(MID_GRID).Checked = -GetPrivateProfileInt(APP_NAME, KEY_GRID, 0, INI_FILENAME)
  1346.     Menu_ViewSelection(MID_LINE_GRID).Checked = -GetPrivateProfileInt(APP_NAME, KEY_LINE_GRID, 1, INI_FILENAME)
  1347.     Menu_ViewSelection(MID_DOTTED_GRID).Checked = -GetPrivateProfileInt(APP_NAME, KEY_DOTTED_GRID, 0, INI_FILENAME)
  1348.     Menu_ViewSelection(MID_FOCUS).Checked = -GetPrivateProfileInt(APP_NAME, KEY_FOCUS, 1, INI_FILENAME)
  1349.     Menu_ViewSelection(MID_BORDER).Checked = -GetPrivateProfileInt(APP_NAME, KEY_BORDER, 1, INI_FILENAME)
  1350.     Menu_ViewSelection(MID_POPUP_MENU).Checked = -GetPrivateProfileInt(APP_NAME, KEY_POPUP, 1, INI_FILENAME)
  1351.     ' Get all Checked Color Menu item values
  1352.     Menu_ColorSelection(MID_DEFAULT_COLORS).Checked = -GetPrivateProfileInt(APP_NAME, KEY_DEFAULT, 1, INI_FILENAME)
  1353.     Menu_ColorSelection(MID_SOLID_COLORS).Checked = -GetPrivateProfileInt(APP_NAME, KEY_SOLID, 0, INI_FILENAME)
  1354.     Menu_ColorSelection(MID_INI_COLORS).Checked = -GetPrivateProfileInt(APP_NAME, KEY_INI, 0, INI_FILENAME)
  1355.     ' Enable or Disable the Grid type menu items based on the Check value
  1356.     Menu_ViewSelection(MID_LINE_GRID).Enabled = Menu_ViewSelection(MID_GRID).Checked
  1357.     Menu_ViewSelection(MID_DOTTED_GRID).Enabled = Menu_ViewSelection(MID_GRID).Checked
  1358.     ' Set initial color palette
  1359.     If Menu_ColorSelection(MID_DEFAULT_COLORS).Checked Then Index = MID_DEFAULT_COLORS
  1360.     If Menu_ColorSelection(MID_SOLID_COLORS).Checked Then Index = MID_SOLID_COLORS
  1361.     If Menu_ColorSelection(MID_INI_COLORS).Checked Then Index = MID_INI_COLORS
  1362.     Menu_ColorSelection_Click Index
  1363. End Sub
  1364.  
  1365. ' In response to an Edit.Invert menu item selection, this routine
  1366. ' Inverts the Colors of the selection region.  Using a DrawMode
  1367. ' of INVERSE, a filled box is drawn over the selected region, which
  1368. ' inverts the colors.
  1369. Sub Invert_Selection ()
  1370.     Pic_TempImage.DrawMode = INVERSE
  1371.     Pic_Work.DrawMode = INVERSE
  1372.     ' Invert Selected Region.  Do not need to Invert Mask.
  1373.     Pic_TempImage.Line (X1SelectFrom, Y1SelectFrom)-(X2SelectFrom, Y2SelectFrom), , BF
  1374.     Pic_Work.Line (X1SelectFrom, Y1SelectFrom)-(X2SelectFrom, Y2SelectFrom), , BF
  1375.     Pic_TempImage.DrawMode = COPY_PEN
  1376.     Pic_Work.DrawMode = COPY_PEN
  1377.     If MovingSelection Then Draw_Selection_Rectangle Else Commit_Selection False
  1378.     Magnify_Icon X1SelectFrom, Y1SelectFrom, (X2SelectFrom), (Y2SelectFrom)
  1379. End Sub
  1380.  
  1381. ' Once an object, Line, Square, Filled Square, Circle, or Filled Circle
  1382. ' has been size to what the user wants, this routine is called from the
  1383. ' MouseUp event for the Editing area (Pic_Edit) to display the actual
  1384. ' object.
  1385. Sub Line_To_Filled_Circle_MouseUp (X1, Y1, X2, Y2)
  1386.     Pic_Image.DrawWidth = BrushSize
  1387.     Pic_Mask.DrawWidth = BrushSize
  1388.     If CurrentTool = TID_FILLED_SQUARE Or CurrentTool = TID_FILLED_CIRCLE Then
  1389.         Pic_Image.FillStyle = Solid
  1390.         Pic_Mask.FillStyle = Solid
  1391.     End If
  1392.     ' Scale the dimensions of the object from the Editing area down
  1393.     ' to that of the Icon, 32x32.
  1394.     Scale_Region True, X1, Y1, X2, Y2, False
  1395.     Select Case CurrentTool
  1396.         Case TID_LINE
  1397.             Pic_Image.Line (X1, Y1)-(X2, Y2)
  1398.             '
  1399.             ' Draw end-point only if BrushSize is one Pixel
  1400.             If BrushSize = 1 Then Pic_Image.PSet (X2, Y2)
  1401.             Pic_Mask.Line (X1, Y1)-(X2, Y2)
  1402.             If BrushSize = 1 Then Pic_Mask.PSet (X2, Y2)
  1403.         Case TID_SQUARE, TID_FILLED_SQUARE
  1404.             Pic_Image.Line (X1, Y1)-(X2, Y2), , B
  1405.             Pic_Mask.Line (X1, Y1)-(X2, Y2), , B
  1406.         Case TID_CIRCLE, TID_FILLED_CIRCLE
  1407.             If Valid_Circle(X1, Y1, X2, Y2) Then
  1408.                 Pic_Image.Circle (XCenter, YCenter), Radius, , , , Aspect
  1409.                 Pic_Mask.Circle (XCenter, YCenter), Radius, , , , Aspect
  1410.                 Radius = 0
  1411.             End If
  1412.     End Select
  1413.     If X1 > X2 Then Swap_Values X1, X2
  1414.     If Y1 > Y2 Then Swap_Values Y1, Y2
  1415.     Pic_Image.DrawWidth = 1
  1416.     Pic_Mask.DrawWidth = 1
  1417.     Pic_Image.FillStyle = TRANSPARENT
  1418.     Pic_Mask.FillStyle = TRANSPARENT
  1419.  
  1420.     ' Only the area modified is redisplayed, which is the rectangle
  1421.     ' defined by the values of X1, Y1, X2, Y2.  If the Brushsize is
  1422.     ' greater than 1 pixel, then the actual area modified is slightly
  1423.     ' larger than the this rectangle, so the values X1, Y1, X2, Y2
  1424.     ' must be adjusted to include the thickness of the Brushsize so
  1425.     ' the entire area modified is redisplayed.
  1426.     '
  1427.     If (BrushSize > 1) And (CurrentTool >= TID_LINE) Then
  1428.         Adjustment = BrushSize \ 2
  1429.         X1 = X1 - Adjustment - 1
  1430.         Y1 = Y1 - Adjustment - 1
  1431.         X2 = X2 + Adjustment + 1
  1432.         Y2 = Y2 + Adjustment + 1
  1433.     End If
  1434.  
  1435. End Sub
  1436.  
  1437. ' For the Line, Square, Filled Square, Circle, and Filled Circle Tools,
  1438. ' an Inverted resizeable version of the object is displayed in response
  1439. ' to a MouseMove.  The object is anchored at the point set by the MouseDown
  1440. ' event within the Editing area.  This routine is called to erase the
  1441. ' old object and display the new object during a MouseMove event.
  1442. '
  1443. Sub Line_To_Filled_Circle_Tool_Move (Shift As Integer, x As Single, Y As Single)
  1444. Static LastCircleGood
  1445.  
  1446.     ' Erase Old object
  1447.     '
  1448.     Draw_Line_Or_Box
  1449.     If (CurrentTool >= TID_CIRCLE) And LastCircleGood Then Pic_Edit.Circle (XCenter, YCenter), Radius, , , , Aspect
  1450.     Adjust_X_and_Y x, Y, X2Region, Y2Region, TO_CENTER
  1451.  
  1452.     ' Holding the Shift key down forces a perfect Square or Circle.
  1453.     ' For a line, it forces either a Horizontal, Vertical or 45 degree
  1454.     ' line to be displayed.
  1455.     '
  1456.     If Shift And SHIFT_MASK Then Make_Region_Square
  1457.  
  1458.     If CurrentTool >= TID_CIRCLE Then
  1459.         '
  1460.         ' When sizing a circle, a rectangle with the circle displayed
  1461.         ' within the circle is drawn.  This is done to give a better
  1462.         ' feeling that the mouse is attached to the object when sizing.
  1463.         ' The rectanle is not drawn one the mouse is released.
  1464.         '
  1465.         LastCircleGood = Valid_Circle(X1Region, Y1Region, X2Region, Y2Region)
  1466.         If LastCircleGood Then Pic_Edit.Circle (XCenter, YCenter), Radius, , , , Aspect
  1467.     End If
  1468.  
  1469.     ' Draw New Object
  1470.     '
  1471.     Draw_Line_Or_Box
  1472.  
  1473. End Sub
  1474.  
  1475. ' To make creating a perfect Square, Circle, or a Diagonal, Vertical,
  1476. ' or Horizontal line, the routine is called whenever the Shift key
  1477. ' is depressed in conjuction to dragging the Mouse within the Editing
  1478. ' area.  This routine adjusts the actual mouse coordinates so that
  1479. ' the displayed object is Square, or in the case of a line, Diagonal,
  1480. ' Vertical, or Horizontal.
  1481. '
  1482. Sub Make_Region_Square ()
  1483.     
  1484.     Xside = Abs(X2Region - X1Region)
  1485.     Yside = Abs(Y2Region - Y1Region)
  1486.     If Xside > Yside Then RectSide = Xside Else RectSide = Yside
  1487.     X2Region = X1Region + RectSide * Sgn(X2Region - X1Region)
  1488.     Y2Region = Y1Region + RectSide * Sgn(Y2Region - Y1Region)
  1489.  
  1490. End Sub
  1491.  
  1492. ' Changes size of brush to either 1x1, 3x3, or 5x5, and
  1493. ' Checks the corresponding Bush menu item
  1494. '
  1495. Sub Menu_BrushSelection_Click (Index As Integer)
  1496.   
  1497.     Menu_BrushSelection(BrushSize).Checked = False
  1498.     Menu_BrushSelection(Index).Checked = True
  1499.     BrushSize = Index
  1500.  
  1501. End Sub
  1502.  
  1503. ' Processes all Color Menu selections.
  1504. '
  1505. Sub Menu_ColorSelection_Click (Index As Integer)
  1506.     
  1507.     Select Case Index
  1508.  
  1509.         Case MID_COLORS
  1510.             '
  1511.             ' Invoke Custom ColorPalette form
  1512.             '
  1513.             ColorIndex = 0
  1514.             ColorPalette.Show
  1515.  
  1516.         Case MID_DEFAULT_COLORS
  1517.             '
  1518.             ' Default color palette is the same colors as the VB colorpalette
  1519.             '
  1520.             Extract_Colors_From_String DEFAULT_COLORS_ROW1, 0, False
  1521.             Extract_Colors_From_String DEFAULT_COLORS_ROW2, 16, False
  1522.             Extract_Colors_From_String DEFAULT_COLORS_ROW3, 32, True
  1523.         
  1524.         Case MID_SOLID_COLORS
  1525.             '
  1526.             ' Solid colors are the 16 colors returned from QBColors()
  1527.             '
  1528.             Menu_ColorSelection(MID_SOLID_COLORS).Checked = True
  1529.             Show_Solid_Colors_Only
  1530.  
  1531.         Case MID_INI_COLORS
  1532.             '
  1533.             ' If there are Colors saved to the INI file, they will
  1534.             ' be displayed, otherwise, the Default colors will be displayed
  1535.             '
  1536.             Menu_ColorSelection(MID_INI_COLORS).Checked = True
  1537.             Get_INI_File_Colors
  1538.  
  1539.         Case MID_SAVE_COLORS
  1540.             Save_Colors_To_INI_File
  1541.  
  1542.         Case MID_LEFT_RIGHT, MID_SCREEN_INVERSE
  1543.             '
  1544.             ' Same functionality as clicking either of the Mouse Option buttons
  1545.             '
  1546.             Opt_Mouse(Index - MID_LEFT_RIGHT).Value = True
  1547.     
  1548.     End Select
  1549.  
  1550.     ' If the selection was 1 of the 3 colorpalette selections, Check
  1551.     ' the current selection, and Uncheck the previous selection.
  1552.     '
  1553.     If (Index >= MID_DEFAULT_COLORS) And (Index <= MID_INI_COLORS) Then
  1554.         Menu_ColorSelection(MID_DEFAULT_COLORS).Checked = (Index = MID_DEFAULT_COLORS)
  1555.         Menu_ColorSelection(MID_SOLID_COLORS).Checked = (Index = MID_SOLID_COLORS)
  1556.         Menu_ColorSelection(MID_INI_COLORS).Checked = (Index = MID_INI_COLORS)
  1557.     End If
  1558.  
  1559. End Sub
  1560.  
  1561. ' Prepares the Edit menus Sub menu items, by Enabling or Disabling
  1562. ' the menu items depending on whether there is a current selection
  1563. ' or if the current selection is being moved, and the current format
  1564. ' of the system ClipBoard.
  1565. '
  1566. Sub Menu_Edit_Click ()
  1567.  
  1568.     Menu_EditSelection(MID_CUT).Enabled = Selecting And Not MovingSelection
  1569.     Menu_EditSelection(MID_COPY).Enabled = Selecting And Not MovingSelection
  1570.     Menu_EditSelection(MID_PASTE).Enabled = Clipboard.GetFormat(CF_BITMAP)
  1571.     Menu_EditSelection(MID_PASTE_OPAQUE).Enabled = Clipboard.GetFormat(CF_BITMAP)
  1572.     Menu_EditSelection(MID_DELETE).Enabled = Selecting And Not MovingSelection
  1573.     Menu_EditSelection(MID_FLIP_HORIZONTAL).Enabled = Selecting
  1574.     Menu_EditSelection(MID_FLIP_VERTICAL).Enabled = Selecting
  1575.     Menu_EditSelection(MID_ROTATE_LEFT).Enabled = Selecting And (Not MovingSelection) And ((X2Region - X1Region) = (Y2Region - Y1Region))
  1576.     Menu_EditSelection(MID_ROTATE_RIGHT).Enabled = Selecting And (Not MovingSelection) And ((X2Region - X1Region) = (Y2Region - Y1Region))
  1577.     Menu_EditSelection(MID_INVERT).Enabled = Selecting
  1578.  
  1579. End Sub
  1580.  
  1581. ' Processes all Edit Menu selections.
  1582. '
  1583. Sub Menu_EditSelection_Click (Index As Integer)
  1584.     Select Case Index
  1585.  
  1586.         Case MID_UNDO
  1587.             UnDo_Edits
  1588.  
  1589.         Case MID_CUT, MID_COPY, MID_DELETE
  1590.             Cut_Copy_Or_Delete_Selection Index
  1591.             
  1592.         Case MID_PASTE, MID_PASTE_OPAQUE
  1593.             Paste_ClipBoard_Contents Index
  1594.  
  1595.         Case MID_SELECT_All
  1596.             Select_Entire_Icon
  1597.  
  1598.         Case MID_FLIP_HORIZONTAL, MID_FLIP_VERTICAL
  1599.             Flip_Selection Index
  1600.  
  1601.         Case MID_ROTATE_RIGHT, MID_ROTATE_LEFT
  1602.             Rotate_Selection Index
  1603.  
  1604.         Case MID_INVERT
  1605.             Invert_Selection
  1606.  
  1607.     End Select
  1608.     
  1609. End Sub
  1610.  
  1611. ' Processes all File Menu selections.
  1612. '
  1613. Sub Menu_FileSelection_Click (Index As Integer)
  1614.  
  1615.     Select Case Index
  1616.  
  1617.         Case MID_NEW
  1618.             Prepare_For_New_Icon
  1619.       
  1620.         Case MID_OPEN
  1621.             Viewer.Show MODELESS
  1622.  
  1623.         Case MID_SAVE, MID_SAVE_AS
  1624.             Save_Icon Index
  1625.  
  1626.         Case MID_EXIT
  1627.             Unload Editor
  1628.  
  1629.     End Select
  1630.  
  1631. End Sub
  1632.  
  1633. ' Processes all Help Menu selections.
  1634. '
  1635. Sub Menu_HelpSelection_Click (Index As Integer)
  1636.  
  1637.     If Index = MID_ABOUT Then
  1638.         AboutBox.Show MODAL
  1639.     Else
  1640.         Get_Help Index
  1641.     End If
  1642.  
  1643. End Sub
  1644.  
  1645. ' Processes all Icons Menu selections.  Same as clicking
  1646. ' one of the Icons within the StatusArea.
  1647. '
  1648. Sub Menu_IconsSelection_Click (Index As Integer)
  1649.  
  1650.     Pic_Icons_MouseDown Index, LEFT_BUTTON, 0, 0, 0
  1651.   
  1652. End Sub
  1653.  
  1654. ' Prepares for the Tools sub menu to be shown, by Checking
  1655. ' the currently selected tool.
  1656. '
  1657. Sub Menu_Tools_Click ()
  1658.  
  1659.     Menu_ToolsSelection(CurrentTool).Checked = True
  1660.  
  1661. End Sub
  1662.  
  1663. ' Processes all Tools Menu selections.  Same as clicking any
  1664. ' tool within the ToolPalette
  1665. '
  1666. Sub Menu_ToolsSelection_Click (Index As Integer)
  1667.  
  1668.     Pic_ToolPalette_MouseDown LEFT_BUTTON, 0, 0, Index * 32
  1669.     
  1670. End Sub
  1671.  
  1672. ' Processes all View Menu selections.
  1673. '
  1674. Sub Menu_ViewSelection_Click (Index As Integer)
  1675.  
  1676.     Select Case Index
  1677.  
  1678.         Case MID_STATUS_BAR, MID_TOOL_PALETTE, MID_COLOR_PALETTE, MID_ZOOM_SCROLLBAR, MID_FOCUS, MID_BORDER, MID_POPUP_MENU
  1679.             Menu_ViewSelection(Index).Checked = Not Menu_ViewSelection(Index).Checked
  1680.             If Index = MID_BORDER Then
  1681.                 HighLight_Current_Icon
  1682.             ElseIf Index < MID_FOCUS Then
  1683.                 '
  1684.                 ' Must process a From_Resize to make the Above selection
  1685.                 ' take affect since all hiding and showing of palettes is
  1686.                 ' done within the Form_Resize event.
  1687.                 '
  1688.                 Form_Resize
  1689.             End If
  1690.  
  1691.         Case MID_SHOW_ALL
  1692.             For I = 0 To 3
  1693.                 Menu_ViewSelection(I).Checked = True
  1694.             Next I
  1695.             Form_Resize
  1696.  
  1697.         Case MID_GRID
  1698.             Activate_Grid
  1699.  
  1700.         Case MID_LINE_GRID, MID_DOTTED_GRID
  1701.             Select_Grid_Type Index
  1702.  
  1703.         Case MID_ZOOM_IN
  1704.             Scrl_Zoom.Value = Scrl_Zoom.Value + 32
  1705.  
  1706.         Case MID_ZOOM_OUT
  1707.             Scrl_Zoom.Value = Scrl_Zoom.Value - 32
  1708.       
  1709.     End Select
  1710.   
  1711.     If ((Index = MID_STATUS_BAR) Or (Index = MID_SHOW_ALL)) And Menu_ViewSelection(MID_STATUS_BAR).Checked Then Display_Color_Palette Pic_ColorPalette
  1712.  
  1713. End Sub
  1714.  
  1715. ' One of the Mouse Button Options Buttons was selected, so update
  1716. ' the corresponding Color menu items Checked value.
  1717. '
  1718. Sub Opt_Mouse_Click (Index As Integer)
  1719.     
  1720.     Menu_ColorSelection(MID_LEFT_RIGHT).Checked = Not (-Index)
  1721.     Menu_ColorSelection(MID_SCREEN_INVERSE).Checked = -Index
  1722.  
  1723. End Sub
  1724.  
  1725. ' The paint tools is the only tool that paints directly to the
  1726. ' Editing area during the MouseMove event.  This routine draws
  1727. ' the pixels to the Icons Image and Mask, and to the Editing area,
  1728. ' so, there is no need to redisplay teh modified area of the Icon
  1729. ' in response to a MouseUp event.  However, the StatusArea Icon
  1730. ' will not display the modificatioin until a MouseUp event.
  1731. '
  1732. Sub Paint_Tool_Move (Xpix, Ypix)
  1733.                 
  1734.     ' Adjust Mouse position so it is centered within the Pixel being
  1735.     ' drawn.
  1736.     '
  1737.     Adjustment = BrushSize \ 2
  1738.     X1 = Xpix - Adjustment
  1739.     Y1 = Ypix - Adjustment
  1740.     X2 = Xpix + Adjustment
  1741.     Y2 = Ypix + Adjustment
  1742.  
  1743.     ' Draw pixel on Icons Image and Mask
  1744.     '
  1745.     Pic_Image.Line (X1, Y1)-(X2, Y2), , BF
  1746.     Pic_Mask.Line (X1, Y1)-(X2, Y2), , BF
  1747.  
  1748.     ' Draw pixel on Editing area
  1749.     '
  1750.     X2 = X2 + 1
  1751.     Y2 = Y2 + 1
  1752.     Pic_Edit.Line (X1 * PixelSize, Y1 * PixelSize)-(X2 * PixelSize - 1, Y2 * PixelSize - 1), , BF
  1753.  
  1754.     ' Redisplay Grid in modified area if Grid is selected.
  1755.     '
  1756.     If Menu_ViewSelection(MID_GRID).Checked Then Display_Grid (Pic_Edit.hDC), X1, Y1, X2, Y2
  1757.  
  1758. End Sub
  1759.  
  1760. ' In response to an Edit.Paste or Edit.Paste Opaque, this routine is called
  1761. ' to perform the acutal paste operation.  There are two forms of the Paste:
  1762. '
  1763. '   Paste Shift+Ins:  Creates a Mask from the bitmap in the clipboard
  1764. '                     based on the current Screen Color selected.  All
  1765. '                     Pixels in the Bitmap that match the Screen Color
  1766. '                     become transparent.
  1767. '
  1768. '   Paste Opaque Ctrl+Shift+Ins:  No mask is created from the bitmap and
  1769. '                     It is pasted as is with no Screen Color attributes.
  1770. '
  1771. Sub Paste_ClipBoard_Contents (Index)
  1772.             
  1773.     ' Get Bitmap from System Clipboard
  1774.     '
  1775.     Pic_Work.Picture = Clipboard.GetData(CF_BITMAP)
  1776.  
  1777.     ' Determine if Bitmap is too large to paste.  Must be 32x32 pixels or
  1778.     ' smaller.
  1779.     '
  1780.     If Pic_Work.Width <= 32 And Pic_Work.Height <= 32 Then
  1781.         '
  1782.         ' Change tool selection to SelectTool, which will allow us to
  1783.         ' move the Bitmap being pasted to anywhere within the Icon.
  1784.         '
  1785.         Pic_ToolPalette_MouseDown LEFT_BUTTON, 0, 0, TID_SELECT * 32
  1786.         
  1787.         Pic_TempImage.Picture = Pic_Work.Image
  1788.         Opaque = MID_PASTE - Index
  1789.  
  1790.         If Opaque Then
  1791.             ' An Opaque paste, so the Bitmap is pasted as is.  So we simply create
  1792.             ' a solid Black mask.
  1793.             '
  1794.             Pic_TempMask.Line (0, 0)-(Pic_TempMask.ScaleWidth, Pic_TempMask.ScaleHeight), BLACK, BF
  1795.         Else
  1796.             ' A normal paste, so a Mask must be created from the Bitmap being pasted,
  1797.             ' based on the currently selected Screen color.  The Mask is created, by
  1798.             ' BitBlt'ing the the 16-color bitmap to a mono Hdc.  All pixels in the color
  1799.             ' bitmap which are the screen color will be white in the monochrome bitmap,
  1800.             ' all others will be black.  That is why the Backcolor of the Picture control
  1801.             ' containing the bitmap is first set to the currently selected Screen color.
  1802.             ' This Monochrome bitmap is then BitBlt'd back to a 16-Color Picture control
  1803.             ' so we can easily manipulate it.
  1804.             '
  1805.             Pic_Work.BackColor = MouseColors(2)
  1806.             R = BitBlt(MonoHdc, 0, 0, Pic_Work.Width, Pic_Work.Height, Pic_Work.hDC, 0, 0, SRCCOPY)
  1807.             R = BitBlt(Pic_TempMask.hDC, 0, 0, Pic_Work.Width, Pic_Work.Height, MonoHdc, 0, 0, SRCCOPY)
  1808.                     
  1809.             ' Once the Mask is created, all the pixels in the Image bitmap which are of
  1810.             ' currently selected screen color must be changed to Black.  To do this we
  1811.             ' Logically AND the Mask created above with the Image bitmap.  This has the
  1812.             ' affect of turning all pixels which are not the screen color to Black, leaving
  1813.             ' screen color pixels unaffected.  We then XOR the image with this result, which
  1814.             ' gives us the desired result of all screen color pixels of the origianl
  1815.             ' bitmap going to Black, all other pixels are unaffected.
  1816.             '
  1817.             R = BitBlt(Pic_TempImage.hDC, 0, 0, Pic_Work.Width, Pic_Work.Height, Pic_TempMask.hDC, 0, 0, SRCAND)
  1818.             R = BitBlt(Pic_TempImage.hDC, 0, 0, Pic_Work.Width, Pic_Work.Height, Pic_Work.hDC, 0, 0, SRCINVERT)
  1819.         End If
  1820.  
  1821.         If (Pic_Work.Width = 32) And (Pic_Work.Height = 32) Then
  1822.             ' Bitmap Pasted is too large to allow it to be moved, so we
  1823.             ' commit the Bitmap to the Icon with out allowing it to be
  1824.             ' moved, and then redisplay the Icon.
  1825.             '
  1826.             Scale_Region False, 0, 0, 32, 32, False
  1827.             Scale_Region True, X1SelectFrom, Y1SelectFrom, X2SelectFrom, Y2SelectFrom, False
  1828.             Commit_Selection True
  1829.             Magnify_Icon 0, 0, 31, 31
  1830.         Else
  1831.             ' The Bitmap pasted can be moved, so go into Move mode by setting
  1832.             ' the appropriate flags.
  1833.             '
  1834.             Selecting = True
  1835.             Moveable = True
  1836.             MovingSelection = True
  1837.  
  1838.             ' Set the Selection Region to the size of the Bitmap pasted, in
  1839.             ' both the scale of the Icon and the Magnified Icon.
  1840.             '
  1841.             Scale_Region False, 0, 0, (Pic_Work.Width), (Pic_Work.Height), False
  1842.             Scale_Region True, X1SelectFrom, Y1SelectFrom, X2SelectFrom, Y2SelectFrom, True
  1843.             Scale_Region True, LastX1, LastY1, LastX2, LastY2, True
  1844.  
  1845.             ' Redisplay Icon.  Passing a values of 0,0,0,0 simply force the Magnify_Icon
  1846.             ' routine to magnify the pasted Bitmap over the top of the magnified Icon.
  1847.             '
  1848.             Magnify_Icon 0, 0, 0, 0
  1849.         End If
  1850.     Else
  1851.         ' Bitmap was too large to paste, so prompt the user.
  1852.         '
  1853.         Pic_Work.Picture = LoadPicture()
  1854.         MsgBox "ClipBoard image is too large:  " + Format$(Pic_Work.Width) + " x " + Format$(Pic_Work.Height) + CRLF + "Image not pasted", 16, "Error"
  1855.     End If
  1856.  
  1857. End Sub
  1858.  
  1859. ' ColorPalette operations are performed on the MouseUp event,
  1860. ' and DoubleClicking the ColorPalette invokes the Custom
  1861. ' color ColorPalette Form so a flag must be set to inform the
  1862. ' MouseUp event to invoke the Custom ColorPalette form.
  1863. '
  1864. Sub Pic_ColorPalette_DblClick ()
  1865.  
  1866.     DoubleClicked = True
  1867.  
  1868. End Sub
  1869.  
  1870. ' Checks if Mouse Coordinates are within the ColorPalette, since the mouse
  1871. ' could have been dragged outside of the ColorPalette between the MouseDown
  1872. ' and MouseUp events, in which case the ColorPalette would still get the
  1873. ' MouseUp event with coordinates outside the actual ColorPalette which would
  1874. ' generate and error when accessing the Color Array.
  1875. '
  1876. Sub Pic_ColorPalette_MouseUp (Button As Integer, Shift As Integer, x As Single, Y As Single)
  1877.     
  1878.     If (x >= 0) And (x <= 16) And (Y >= 0) And (Y <= 3) Then Update_Mouse_Colors Button, x, Y
  1879.  
  1880. End Sub
  1881.  
  1882. Sub Pic_ColorPalette_Paint ()
  1883.  
  1884.     Display_Color_Palette Pic_ColorPalette
  1885.  
  1886. End Sub
  1887.  
  1888. ' If the Icon dropped is from the Viewer, it is loaded into the
  1889. ' currently selected Icon, otherwise nothing is done.
  1890. '
  1891. Sub Pic_Edit_DragDrop (Ctl As Control, x As Single, Y As Single)
  1892.  
  1893.     If Ctl.Parent.Tag <> Editor.Tag Then Load_An_Icon
  1894.  
  1895. End Sub
  1896.  
  1897. ' If the Icon being dragged is from the Viewer and it has just entered
  1898. ' or left the Edit area, invert the Edit area.
  1899. '
  1900. Sub Pic_Edit_DragOver (Ctl As Control, x As Single, Y As Single, State As Integer)
  1901.  
  1902.     If (Ctl.Parent.Tag <> Editor.Tag) And (State <> OVER) Then Invert_Control Pic_Edit
  1903.  
  1904. End Sub
  1905.  
  1906. ' A MouseDown event in the Editing area signals the beginning of a new
  1907. ' Tool operation if a tool operation is not already in progress.  All
  1908. ' preparation for the Tool operation is performed here, within the
  1909. ' MouseDown event.
  1910. '
  1911. Sub Pic_Edit_MouseDown (Button As Integer, Shift As Integer, x As Single, Y As Single)
  1912.  
  1913.     ' Propare for Tool operation only if there is not an operation already in
  1914.     ' progress, and only one mouse button is down, Left or Right.
  1915.     '
  1916.     If (ToolInProcess = 0) And ((Button = LEFT_BUTTON) Or (Button = RIGHT_BUTTON)) Then
  1917.         '
  1918.         ' Save Button value that started Tool Operation.
  1919.         '
  1920.         ToolInProcess = Button
  1921.  
  1922.         Get_Current_Colors Button
  1923.         Pic_Edit.DrawStyle = Solid
  1924.  
  1925.         If CurrentTool = TID_PAINT Then
  1926.             '
  1927.             ' Begin a Paint tool operation.
  1928.             '
  1929.             Pic_Edit.DrawMode = COPY_PEN
  1930.             
  1931.             ' So a pixel is drawn in repsonse to just a Click within the editing
  1932.             ' area, the MouseMove event must be called since all the actual
  1933.             ' drawing to the Editing area for the Paint Tool is done within the
  1934.             ' MouseMove event.
  1935.             '
  1936.             Pic_Edit_MouseMove Button, 0, x, Y
  1937.  
  1938.         ElseIf CurrentTool <> TID_FILL Then
  1939.             '
  1940.             ' Prepare for all other tools other than Fill and Paint tools.
  1941.             '
  1942.             Pic_Edit.DrawMode = INVERSE
  1943.             If CurrentTool = TID_SELECT Then Adjustment = TO_EDGE Else Adjustment = TO_CENTER
  1944.  
  1945.             ' Determine if a Selection is in process, the Selection can be moved,
  1946.             ' and whether the MousePointer is within the current selection.
  1947.             '
  1948.             If Selecting And Moveable And ((x >= X1Region) And (x <= X2Region) And (Y >= Y1Region) And (Y <= Y2Region)) Then
  1949.                 '
  1950.                 ' The selection is moveable and the MousePointer is within the
  1951.                 ' selection.  So prepare for a move.
  1952.                 '
  1953.                 Adjust_X_and_Y x, Y, XMoveSelection, YMoveSelection, Adjustment
  1954.                 If Button = RIGHT_BUTTON Then Opaque = True Else Opaque = False
  1955.  
  1956.                 If Not MovingSelection Then
  1957.                     '
  1958.                     ' The selection has not yet been moved from its original
  1959.                     ' position, so prepare to move selection.
  1960.                     '
  1961.                     ' If the Shift key is down, then the a copy of the Selection
  1962.                     ' will be moved, otherwise the selection will be move from
  1963.                     ' its current location so its previous location must be deleted.
  1964.                     '
  1965.                     If (Shift And SHIFT_MASK) = 0 Then Delete_Selection_From_Icon
  1966.                     Draw_Selection_Rectangle
  1967.                     MovingSelection = True
  1968.                     Draw_Selection_Rectangle
  1969.  
  1970.                 ElseIf (Shift And SHIFT_MASK) Then
  1971.                     '
  1972.                     ' The selection has already been moved from its original
  1973.                     ' location and is being moved again.  If the Shift key is
  1974.                     ' down, make a copy of the selection at its current location
  1975.                     ' and continue the move.
  1976.                     '
  1977.                     Commit_Selection False
  1978.                     Draw_Selection_Rectangle
  1979.                 End If
  1980.             Else
  1981.                 '
  1982.                 ' No selection is in progress, or a selection is in progress
  1983.                 ' but the MousePointer is not within the current selection,
  1984.                 ' or a tool other than the Select tool is in use.
  1985.                 '
  1986.                 ' If a Selection is in progress, commit the Selection at its
  1987.                 ' current location.
  1988.                 '
  1989.                 If Selecting Then Commit_Selection True
  1990.  
  1991.                 ' Prepare for new Tool operation
  1992.                 '
  1993.                 Opaque = True
  1994.                 Adjust_X_and_Y x, Y, X1Region, Y1Region, Adjustment
  1995.                 X2Region = X1Region
  1996.                 Y2Region = Y1Region
  1997.             End If
  1998.         End If
  1999.  
  2000.     End If
  2001.  
  2002. End Sub
  2003.  
  2004. ' For all tools except for the Paint tool and Fill tool, the MouseMove
  2005. ' event is used to size the object to be drawn.  The actual object is
  2006. ' drawn within the MouseUp event based on the coodinates obtained here
  2007. ' in the MouseMove event.  The Paint tool, however, does all of its
  2008. ' actual drawing to the Editing area within the MouseMove event.  The
  2009. ' Fill tool does nothing until the MouseUp event.
  2010. '
  2011. Sub Pic_Edit_MouseMove (Button As Integer, Shift As Integer, x As Single, Y As Single)
  2012.   
  2013.     ' Calculate pixel mouse is currently over.
  2014.     '
  2015.     Xpix = x \ PixelSize
  2016.     Ypix = Y \ PixelSize
  2017.  
  2018.     ' The Mouse coordinates are always displayed within the StatusArea
  2019.     '
  2020.     Display_Mouse_Coordinates Xpix, Ypix
  2021.  
  2022.     ' Depending on the Current tool, and in the case of the Select tool,
  2023.     ' the state of the Selection, the MousePointer may change.
  2024.     '
  2025.     Set_MousePointer x, Y
  2026.  
  2027.     ' We only want to process the MouseMove event if the Button causing
  2028.     ' the MouseMove event is the same that started the operation.
  2029.     ' The value of the Button that started the operation is stored in
  2030.     ' the global variable ToolInProcess which is set in the MouseDown event.
  2031.     '
  2032.     If (Button = ToolInProcess) And (ToolInProcess <> 0) Then
  2033.     
  2034.         Select Case CurrentTool
  2035.  
  2036.             Case TID_SELECT
  2037.                 Select_Tool_Move Shift, x, Y
  2038.  
  2039.             Case TID_PAINT
  2040.                 Paint_Tool_Move Xpix, Ypix
  2041.  
  2042.             Case TID_LINE To TID_FILLED_CIRCLE
  2043.                 Line_To_Filled_Circle_Tool_Move Shift, x, Y
  2044.  
  2045.         End Select
  2046.  
  2047.     End If
  2048.  
  2049. End Sub
  2050.  
  2051. ' For all tools except for the Paint tool, the actual object drawn
  2052. ' is not drawn until the Mouse Button is released, which is within
  2053. ' the the edit areas MouseUp event.
  2054. '
  2055. Sub Pic_Edit_MouseUp (Button As Integer, Shift As Integer, x As Single, Y As Single)
  2056.  
  2057.     ' There is no operation that occurs with both mouse buttons down,
  2058.     ' so check to make sure that the MouseUp event is due to the release
  2059.     ' of the same button that started the drawing operation.  The global
  2060.     ' variable ToolInProcess holds the value of the Button.
  2061.     '
  2062.     If Button = ToolInProcess Then
  2063.  
  2064.         Pic_Edit.DrawMode = COPY_PEN
  2065.       
  2066.         Select Case CurrentTool
  2067.     
  2068.             Case TID_SELECT
  2069.                 Select_Tool_MouseUp X1, Y1, X2, Y2
  2070.     
  2071.             Case TID_FILL
  2072.                 Fill_Tool_MouseUp x, Y, X2, Y2
  2073.     
  2074.             Case TID_LINE To TID_FILLED_CIRCLE
  2075.                 Line_To_Filled_Circle_MouseUp X1, Y1, X2, Y2
  2076.     
  2077.         End Select
  2078.  
  2079.         ' The Icon needs to be updated to show the affect of the
  2080.         ' Tool operation for all tools except for the Select tool if
  2081.         ' just making a selection, since all that occurs is a Rectangle
  2082.         ' showing the selection is drawn.
  2083.         '
  2084.         If Not ((CurrentTool = TID_SELECT) And (Not MovingSelection)) Then
  2085.             Update_Icon Pic_Icons(CurrentIcon)
  2086.             '
  2087.             ' Redisplay the Icon for all tools except for the Paint tool.
  2088.             ' The paint tool draws directly on the Edit area within the
  2089.             ' MouseMove event.
  2090.             '
  2091.             If SeletedTool <> TID_PAINT Then Magnify_Icon X1, Y1, X2, Y2
  2092.         End If
  2093.     
  2094.         ToolInProcess = False
  2095.  
  2096.         ' Set enabled state of Edit Menu items.
  2097.         '
  2098.         Menu_Edit_Click
  2099.  
  2100.     End If
  2101.  
  2102. End Sub
  2103.  
  2104. Sub Pic_Edit_Paint ()
  2105.  
  2106.     ' Repaint Edit area
  2107.     Magnify_Icon 0, 0, 31, 31
  2108.  
  2109. End Sub
  2110.  
  2111. ' If the Icon dropped is from the Viewer, it is loaded into the
  2112. ' StatusArea Icon on which is was dropped and that icon is made
  2113. ' the current Icon, otherwise nothing is done.
  2114. '
  2115. Sub Pic_Icons_DragDrop (Index As Integer, Ctl As Control, x As Single, Y As Single)
  2116.  
  2117.     If Ctl.Parent.Tag <> Editor.Tag Then
  2118.         CurrentIcon = Index
  2119.         Load_An_Icon
  2120.     End If
  2121.  
  2122. End Sub
  2123.  
  2124. ' If the Icon being dragged is from the Viewer and it has just entered
  2125. ' or left one of the StatusArea Icons, invert the StatusArea icon.
  2126. '
  2127. Sub Pic_Icons_DragOver (Index As Integer, Ctl As Control, x As Single, Y As Single, State As Integer)
  2128.  
  2129.     If (Ctl.Parent.Tag <> Editor.Tag) And (State <> OVER) Then
  2130.         Invert_Control Pic_Icons(Index)
  2131.         Pic_Icons(Index).Refresh
  2132.     End If
  2133.  
  2134. End Sub
  2135.  
  2136. ' Clicking on any of the icons within the StatusArea, makes that
  2137. ' Icon the current Icon.  If the the Icon is already the current
  2138. ' Icon, and selection currently in progress is canceled, and
  2139. ' the Icon can be dragged to test what it looks like begin dragged.
  2140. ' It cannot be dropped on anything.
  2141. '
  2142. Sub Pic_Icons_MouseDown (Index As Integer, Button As Integer, Shift As Integer, x As Single, Y As Single)
  2143.  
  2144.     ' Determine if new Icon is being selected
  2145.     '
  2146.     If (Button = LEFT_BUTTON) And (Index <> CurrentIcon) Then
  2147.         '
  2148.         ' New Icon has been selected, so prepare for new Icon
  2149.         '
  2150.         Menu_IconsSelection(CurrentIcon).Checked = False
  2151.         Menu_IconsSelection(Index).Checked = True
  2152.         If Selecting Then Commit_Selection True
  2153.         CurrentIcon = Index
  2154.         Select_New_Icon
  2155.     ElseIf (Button = LEFT_BUTTON) And (Index = CurrentIcon) Then
  2156.         '
  2157.         ' The current Icon was selected.
  2158.         '
  2159.         If Selecting Then
  2160.             '
  2161.             ' A selection was in progress so cancel it.
  2162.             '
  2163.             Draw_Selection_Rectangle
  2164.             Selecting = False
  2165.             MovingSelection = False
  2166.             Scale_Region True, X1, Y1, X2, Y2, True
  2167.             Magnify_Icon X1, Y1, X2, Y2
  2168.         End If
  2169.         
  2170.         ' Set the DragIcon of the selected Icon, and begin dragging
  2171.         '
  2172.         Pic_Icons(Index).DragIcon = Pic_Icons(Index).Picture
  2173.         Pic_Icons(Index).Drag
  2174.     End If
  2175.  
  2176. End Sub
  2177.  
  2178. ' Although the StatusArea appears as though it contains many controls
  2179. ' it actually contains only 7 picture controls and 2 Option buttons.
  2180. ' The rest of the information displayed within the StatusArea is painted
  2181. ' directly onto the StatusArea.  This is done to limit the actual number
  2182. ' of controls on the Editor.  The more controls, the more System resources
  2183. ' it uses and the longer it takes to load.  It may be easier to display
  2184. ' certain data using controls, but in some cases, its benificial to not
  2185. ' use controls but display the information yourself.  The easiest controls
  2186. ' to eliminate are Labels since they usually just display text and do
  2187. ' not change throughout the life of the program, and the .Print method
  2188. ' can be used to display the text instead of a label.
  2189. '
  2190. Sub Pic_StatusArea_Paint ()
  2191.  
  2192.     ' Calculate center of StatusArea
  2193.     '
  2194.     Middle = Pic_StatusArea.ScaleWidth \ 2
  2195.  
  2196.     ' Set font attributes for X & Y Mouse coodinate display
  2197.     '
  2198.     Pic_StatusArea.FontName = "MS Sans Serif"
  2199.     Pic_StatusArea.FontSize = 8.25
  2200.     Pic_StatusArea.ForeColor = BLACK
  2201.  
  2202.     ' Display X & Y mouse coordinate labels, "X=" and Y="
  2203.     '
  2204.     Pic_StatusArea.CurrentY = Pic_Icons(5).Top + Pic_Icons(5).Height + HIGHLIGHT + 1
  2205.     Pic_StatusArea.CurrentX = (Middle - Pic_StatusArea.TextWidth("XXXX")) \ 2
  2206.     Pic_StatusArea.Print "X=";
  2207.     Pic_StatusArea.CurrentX = Middle + (Middle - Pic_StatusArea.TextWidth("XXXX")) \ 2
  2208.     Pic_StatusArea.Print "Y=";
  2209.     
  2210.     ' If the Undo Icon is visible, display its label, "Undo to:"
  2211.     '
  2212.     If Pic_Undo.Visible Then
  2213.         Text = "Undo to:"
  2214.         Pic_StatusArea.CurrentX = (Pic_Undo.Left - Pic_StatusArea.TextWidth(Text)) \ 2
  2215.         Pic_StatusArea.CurrentY = Pic_Undo.Top + ((Pic_Undo.Height - Pic_StatusArea.TextHeight(Text)) \ 2)
  2216.         Pic_StatusArea.Print "Undo to:"
  2217.     End If
  2218.     
  2219.     ' If the Mouse Option buttons are visible, then display the the
  2220.     ' option button Color labels and the colors themselves.  The labels are
  2221.     ' all based on the positions of the two Option buttons, so it they
  2222.     ' are moved at design time, the labels will still be displayed
  2223.     ' correctly.
  2224.     '
  2225.     If Opt_Mouse(0).Visible Then
  2226.         '
  2227.         ' Display Mouse Butons header label within a White box with a Black
  2228.         ' outline.
  2229.         '
  2230.         Text = "Mouse Buttons"
  2231.         Y1 = Opt_Mouse(0).Top - 1.25 * Opt_Mouse(0).Height
  2232.         Pic_StatusArea.Line (0, Y1)-(Pic_StatusArea.ScaleWidth, Y1 + Pic_StatusArea.TextHeight(Text)), WHITE, BF
  2233.         Pic_StatusArea.Line (0, Y1)-(Pic_StatusArea.ScaleWidth - 1, Y1 + Pic_StatusArea.TextHeight(Text)), BLACK, B
  2234.         Pic_StatusArea.CurrentX = (Pic_StatusArea.ScaleWidth - Pic_StatusArea.TextWidth(Text)) \ 2
  2235.         Pic_StatusArea.CurrentY = Y1
  2236.         Pic_StatusArea.FontTransparent = True
  2237.         Pic_StatusArea.Print Text
  2238.         Pic_StatusArea.FontBold = False
  2239.  
  2240.         ' Display the Mouse Button color labels, centered on either
  2241.         ' side of the Option buttons.
  2242.         '
  2243.         For I = 0 To 3
  2244.             Select Case I
  2245.                 Case 0
  2246.                     Text = "Left"
  2247.                 Case 1
  2248.                     Text = "Right"
  2249.                     Shift = Middle
  2250.                 Case 2
  2251.                     Text = "Screen"
  2252.                     Shift = 0
  2253.                 Case 3
  2254.                     Text = "Inverse"
  2255.                     Shift = Middle
  2256.             End Select
  2257.             Pic_StatusArea.CurrentX = Shift + (Middle - Pic_StatusArea.TextWidth(Text)) \ 2
  2258.             Pic_StatusArea.CurrentY = Opt_Mouse(I \ 2).Top - Pic_StatusArea.TextHeight(Text) - 1
  2259.             Pic_StatusArea.Print Text
  2260.         Next I
  2261.  
  2262.         ' Display the 4 color squares showing currently selected colors
  2263.         ' These could be picture controls.
  2264.         '
  2265.         Display_Mouse_Colors
  2266.     End If
  2267.  
  2268.     ' Set StatusArea font attributes back to that of the Mouse coordinates.
  2269.     '
  2270.     Pic_StatusArea.ForeColor = RED
  2271.     Pic_StatusArea.FontName = "Courier"
  2272.     Pic_StatusArea.FontBold = True
  2273.     Pic_StatusArea.FontTransparent = False
  2274.  
  2275.     HighLight_Current_Icon
  2276.  
  2277. End Sub
  2278.  
  2279. ' Performs a "Select All" opertation, just as though the Edit.Select all
  2280. ' menu item was selected.
  2281. '
  2282. Sub Pic_ToolPalette_DblClick ()
  2283.  
  2284.     If CurrentTool = TID_SELECT Then Menu_EditSelection_Click MID_SELECT_All
  2285.  
  2286. End Sub
  2287.  
  2288. ' Prepare for a new tool.  The actual Tool selection is done within
  2289. ' the MouseMove event.
  2290. '
  2291. Sub Pic_ToolPalette_MouseDown (Button As Integer, Shift As Integer, x As Single, Y As Single)
  2292.     
  2293.     ' Commit and Selection currently being moved.
  2294.     '
  2295.     If Selecting Then Commit_Selection True
  2296.  
  2297.     ' Commit all edits to Undo Icon
  2298.     '
  2299.     Update_Icon Pic_Undo
  2300.  
  2301.     ' Remove Check from current tool in Tools menu
  2302.     '
  2303.     Menu_ToolsSelection(CurrentTool).Checked = False
  2304.  
  2305.     ' Since the actual selection is done within the MouseMove event, and
  2306.     ' a MouseMove event does not occur until the mouse is moved within
  2307.     ' the ToolPalette, we need to call the MouseMove event, to ensure
  2308.     ' the selected tool is in fact selected, since just clicking on
  2309.     ' the ToolPalette does not generate a MouseMove event.
  2310.     '
  2311.     Pic_ToolPalette_MouseMove Button, Shift, x, Y
  2312.  
  2313. End Sub
  2314.  
  2315. ' Moving the mouse within the ToolPalette after a MouseDown event, will select
  2316. ' the tool the mouse is currently over, so you can slide up and down the palette,
  2317. ' and the tool selection will follow the mouse.
  2318. '
  2319. Sub Pic_ToolPalette_MouseMove (Button As Integer, Shift As Integer, x As Single, Y As Single)
  2320.     
  2321.     ' Calculate selected tool.  Each tool Icon is 32 pixels high, so this
  2322.     ' is done easily by Integer dividing the Y coordinate by 32.
  2323.     '
  2324.     NewTool = Y \ 32
  2325.  
  2326.     ' Check to make sure the Mouse is within the Y limits of the ToolPalette
  2327.     ' and not over the currently selected tool.
  2328.     '
  2329.     If (Button <> 0) And (NewTool >= TID_SELECT) And (NewTool <= TID_FILLED_CIRCLE) And (NewTool <> CurrentTool) Then
  2330.         '
  2331.         ' UnHighlight current tool
  2332.         '
  2333.         Pic_ToolPalette.Line (0, CurrentTool * 32 + 1)-(31, CurrentTool * 32 + 31), , BF
  2334.  
  2335.         ' Hightlight new tool
  2336.         '
  2337.         Pic_ToolPalette.Line (0, NewTool * 32 + 1)-(31, NewTool * 32 + 31), , BF
  2338.  
  2339.         CurrentTool = NewTool
  2340.     End If
  2341.   
  2342. End Sub
  2343.  
  2344. Sub Pic_ToolPalette_MouseUp (Button As Integer, Shift As Integer, x As Single, Y As Single)
  2345.     
  2346.     ' Set Enabled state of all Edit menu options.
  2347.     '
  2348.     Menu_Edit_Click
  2349.  
  2350. End Sub
  2351.  
  2352. ' The ToolPalette takes care of painting itself since it contains
  2353. ' a single bitmap displaying the Tools.  However, the currently
  2354. ' selected Tool needs to be Hightlighted during the Paint event.
  2355. '
  2356. Sub Pic_ToolPalette_Paint ()
  2357.     
  2358.     ' Clear ToolPalette to background bitmap of Tools
  2359.     '
  2360.     Pic_ToolPalette.Cls
  2361.  
  2362.     ' HightLight current tool.  The Drawmode of the ToolPalette is
  2363.     ' set to INVERSE, so we simply draw a filled box over the current
  2364.     ' tool.  This inverts the tool.
  2365.     '
  2366.     Pic_ToolPalette.Line (0, CurrentTool * 32 + 1)-(31, CurrentTool * 32 + 31), , BF
  2367.  
  2368. End Sub
  2369.  
  2370. ' Clicking the Undo Icon in the StatusArea is the same thing as
  2371. ' selecting the Edit.Undo menu item.
  2372. '
  2373. Sub Pic_Undo_Click ()
  2374.  
  2375.     Menu_EditSelection_Click MID_UNDO
  2376.  
  2377. End Sub
  2378.  
  2379. ' In response to a File.New menu opertation, this routine is called,
  2380. ' to prepare creating a new Icon from scratch.
  2381. '
  2382. Sub Prepare_For_New_Icon ()
  2383.     
  2384.     ' Determine if current Icon has changed since it was saved last and
  2385.     ' and prompt user if it has been changed and not saved.
  2386.     '
  2387.     If Ok_To_Discard_Changes() Then
  2388.         '
  2389.         ' It is ok to prepare for new Icon.
  2390.         
  2391.         ' Terminate any Selection in progress and simulate a Select all,
  2392.         ' then perform an Edit.Delete operation to clear the Icon.
  2393.         '
  2394.         Selecting = False
  2395.         MovingSelection = False
  2396.         Scale_Region False, 0, 0, 32, 32, False
  2397.         Menu_EditSelection_Click MID_DELETE
  2398.  
  2399.         ' Intialize the IconInfo record to default values
  2400.         '
  2401.         IconInfo(CurrentIcon).FileName = UNTITLED
  2402.         IconInfo(CurrentIcon).Changed = False
  2403.  
  2404.         ' Reset both the Icon menu and the Editors Titlebar
  2405.         '
  2406.         Menu_IconsSelection(CurrentIcon).Caption = "&" + Format$(CurrentIcon + 1) + " - " + UNTITLED
  2407.  
  2408.         Caption = "IconWorks Editor: " + Format$(CurrentIcon + 1) + " - " + UNTITLED
  2409.     End If
  2410.  
  2411. End Sub
  2412.  
  2413. ' Once a Selection has been made, or an Edit.Select All or Edit.Paste
  2414. ' operation has been made, this routine is called to prepare for a
  2415. ' potential movement of the Selection.  A copy of the actual Icons
  2416. ' Mask and Image are made, and this is the Source from which the
  2417. ' Selection is display whenever the Selection is in fact moved.
  2418. '
  2419. Sub Prepare_For_Possible_Move ()
  2420.               
  2421.     Pic_Work.Picture = Pic_Icons(CurrentIcon).Image
  2422.     Pic_TempImage.Picture = Pic_Image.Image
  2423.     Pic_TempMask.Picture = Pic_Mask.Image
  2424.  
  2425. End Sub
  2426.  
  2427. ' When a selection has been made and the selection is Square, it may
  2428. ' be rotated Left or Right by 90 degrees.  Cannot Rotate a selection
  2429. ' that is being moved.  This routine performs the rotation in repsonse
  2430. ' to an Edit.Rotate Left/Right menu operation.
  2431. '
  2432. Sub Rotate_Selection (Index)
  2433.     
  2434.     ' Rotation is not instant, so set Cursor to HourGlass
  2435.     '
  2436.     Screen.MousePointer = HOURGLASS
  2437.  
  2438.     ' Caculate size of Region
  2439.     '
  2440.     NumPixels = X2SelectFrom - X1SelectFrom - 1
  2441.  
  2442.     ' Perform rotation.  The rotation is performed by reading one pixel at
  2443.     ' a time from the source and copying it to is new location in rotated
  2444.     ' either Left or Right 90 degrees.  The Point Method reads the Pixel
  2445.     ' and the Pset method is used to write the pixel.  Both the Icons
  2446.     ' Mask and Image must be rotated.
  2447.     '
  2448.     For Y = 0 To NumPixels
  2449.         For x = 0 To NumPixels
  2450.             If Index = MID_ROTATE_RIGHT Then
  2451.                 '
  2452.                 ' Rotate Right
  2453.                 '
  2454.                 Pic_Image.PSet (X2SelectFrom - Y - 1, Y1SelectFrom + x), Pic_TempImage.Point(X1SelectFrom + x, Y1SelectFrom + Y)
  2455.                 Pic_Mask.PSet (X2SelectFrom - Y - 1, Y1SelectFrom + x), Pic_TempMask.Point(X1SelectFrom + x, Y1SelectFrom + Y)
  2456.             Else
  2457.                 ' Rotate Left
  2458.                 '
  2459.                 Pic_Image.PSet (X1SelectFrom + Y, Y2SelectFrom - x - 1), Pic_TempImage.Point(X1SelectFrom + x, Y1SelectFrom + Y)
  2460.                 Pic_Mask.PSet (X1SelectFrom + Y, Y2SelectFrom - x - 1), Pic_TempMask.Point(X1SelectFrom + x, Y1SelectFrom + Y)
  2461.             End If
  2462.         Next x
  2463.     Next Y
  2464.  
  2465.     ' Replace Icons Mask and Image with new Mask and Images.
  2466.     '
  2467.     Update_Icon Pic_Icons(CurrentIcon)
  2468.     
  2469.     Prepare_For_Possible_Move
  2470.  
  2471.     ' Redisplay selected region to show rotation.
  2472.     '
  2473.     Magnify_Icon X1SelectFrom, Y1SelectFrom, (X2SelectFrom), (Y2SelectFrom)
  2474.  
  2475.     ' Restore Cursor
  2476.     '
  2477.     Screen.MousePointer = DEFAULT
  2478.  
  2479. End Sub
  2480.  
  2481. ' In response to a Color.Save colors to INI file menu operatioin, this
  2482. ' routine is called to write the color values to IconWrks.INI.
  2483. ' WritePrivateProfileString() will create the INI file if it does not
  2484. ' exist, and will create the KeyName if it does not exist in the INI FILE.
  2485. ' The Color values are packed into a single string, one row of colors at
  2486. ' a time, and then written to the INI file.  The colors are formated
  2487. ' into 8-byte fields separated by one space.  After this routine,
  2488. ' IconWrks.INI will contain 3 key entries of:
  2489. '
  2490. '   Colors Row1=16777215 14737632 ...
  2491. '   Colors Row2=12632256 04210752 ...
  2492. '   Colors Row3=08421504 00000000 ...
  2493. '
  2494. Sub Save_Colors_To_INI_File ()
  2495.     
  2496.     For I = 0 To 2
  2497.         ColorString = ""
  2498.         For C = 0 To 15
  2499.             ColorString = ColorString + Format$(Colors(I * 16 + C), "00000000 ")
  2500.         Next C
  2501.         x = WritePrivateProfileString(APP_NAME, KEY_COLOR + Format$(I + 1), ColorString, INI_FILENAME)
  2502.     Next I
  2503.  
  2504. End Sub
  2505.  
  2506. ' In Response to a File.Save or File.Save As menu operation, this routine
  2507. ' is called to either immediately save the Icon or invoke the SaveFileDlg
  2508. ' to get a Filename to save the Icon to.  A File.Save As operation always
  2509. ' invokes the Dialog, but a File.Save will only invoke the Dialog if the
  2510. ' current icon does not yet have a name, denoted by a name of UNTITLED.
  2511. '
  2512. Sub Save_Icon (Index)
  2513.     On Error Resume Next
  2514.     Dim LongName As String
  2515.     Dim Title As String
  2516.     Dim CDPath As String
  2517.  
  2518.     If (Index = MID_SAVE_AS) Or (IconInfo(CurrentIcon).FileName = UNTITLED) Then
  2519.         ' Set default filter.
  2520.         Editor.CMDialog1.Filter = "Icon Files (*.ico)|*.ico"
  2521.         ' Display Save As dialog.
  2522.         Editor.CMDialog1.FilterIndex = 1
  2523.         Editor.CMDialog1.DefaultExt = "ICO"
  2524.         If Right(IconInfo(CurrentIcon).FullPath, 1) <> "\" Then
  2525.           Editor.CMDialog1.Filename = IconInfo(CurrentIcon).FullPath & "\" & IconInfo(CurrentIcon).FileName
  2526.         End If
  2527.         ' If file has not been saved yet, set common dialog's
  2528.         ' default file name to *.ico
  2529.         If IconInfo(CurrentIcon).FileName = "[Untitled]" Then
  2530.           Editor.CMDialog1.Filename = "*.ico"
  2531.         End If
  2532.         
  2533.         Editor.CMDialog1.Action = 2
  2534.         ' Exit if user cancels the dialog.
  2535.         If Err = 32755 Then Exit Sub
  2536.         Title = Editor.CMDialog1.Filetitle
  2537.         LongName = Editor.CMDialog1.Filename
  2538.         IconInfo(CurrentIcon).FullPath = Left(LongName, Len(LongName) - Len(Title))
  2539.         IconInfo(CurrentIcon).FileName = Editor.CMDialog1.Filetitle
  2540.         ' Adjust for root directory.
  2541.         If Len(IconInfo(CurrentIcon).FullPath) = 3 Then
  2542.             CDPath = IconInfo(CurrentIcon).FullPath
  2543.         Else
  2544.             CDPath = Left(LongName, Len(LongName) - Len(Title) - 1)
  2545.         End If
  2546.         ' Change directories for the editor and the viewer.
  2547.         ChDir CDPath
  2548.         Viewer.Dir_DirectoryList.Path = CDPath
  2549.     End If
  2550.         Write_Icon_To_File (IconInfo(CurrentIcon).FullPath), IconInfo(CurrentIcon).FileName
  2551. End Sub
  2552.  
  2553. ' When the Editor is terminated, this routine is called to save all
  2554. ' configurable items of the Editor to the IconWrks.INI file.  Size
  2555. ' and Location of the Editor are not saved.
  2556. '
  2557. ' WritePrivateProfileString() will create the INI file and/or any
  2558. ' KeyName that does not exist.
  2559. '
  2560. Sub Save_Settings_To_INI_File ()
  2561.   
  2562.     R = WritePrivateProfileString(APP_NAME, KEY_GRID, Format$(Abs(Menu_ViewSelection(MID_GRID).Checked)), INI_FILENAME)
  2563.     R = WritePrivateProfileString(APP_NAME, KEY_LINE_GRID, Format$(Abs(Menu_ViewSelection(MID_LINE_GRID).Checked)), INI_FILENAME)
  2564.     R = WritePrivateProfileString(APP_NAME, KEY_DOTTED_GRID, Format$(Abs(Menu_ViewSelection(MID_DOTTED_GRID).Checked)), INI_FILENAME)
  2565.     R = WritePrivateProfileString(APP_NAME, KEY_STATUS_BAR, Format$(Abs(Menu_ViewSelection(MID_STATUS_BAR).Checked)), INI_FILENAME)
  2566.     R = WritePrivateProfileString(APP_NAME, KEY_TOOL_PALETTE, Format$(Abs(Menu_ViewSelection(MID_TOOL_PALETTE).Checked)), INI_FILENAME)
  2567.     R = WritePrivateProfileString(APP_NAME, KEY_COLOR_PALETTE, Format$(Abs(Menu_ViewSelection(MID_COLOR_PALETTE).Checked)), INI_FILENAME)
  2568.     R = WritePrivateProfileString(APP_NAME, KEY_ZOOM_SCROLLBAR, Format$(Abs(Menu_ViewSelection(MID_ZOOM_SCROLLBAR).Checked)), INI_FILENAME)
  2569.     R = WritePrivateProfileString(APP_NAME, KEY_FOCUS, Format$(Abs(Menu_ViewSelection(MID_FOCUS).Checked)), INI_FILENAME)
  2570.     R = WritePrivateProfileString(APP_NAME, KEY_BORDER, Format$(Abs(Menu_ViewSelection(MID_BORDER).Checked)), INI_FILENAME)
  2571.     R = WritePrivateProfileString(APP_NAME, KEY_POPUP, Format$(Abs(Menu_ViewSelection(MID_POPUP_MENU).Checked)), INI_FILENAME)
  2572.     R = WritePrivateProfileString(APP_NAME, KEY_DEFAULT, Format$(Abs(Menu_ColorSelection(MID_DEFAULT_COLORS).Checked)), INI_FILENAME)
  2573.     R = WritePrivateProfileString(APP_NAME, KEY_SOLID, Format$(Abs(Menu_ColorSelection(MID_SOLID_COLORS).Checked)), INI_FILENAME)
  2574.     R = WritePrivateProfileString(APP_NAME, KEY_INI, Format$(Abs(Menu_ColorSelection(MID_INI_COLORS).Checked)), INI_FILENAME)
  2575.  
  2576. End Sub
  2577.  
  2578. ' Scrolling the Zoom scrollbar Zooms in or Zooms out on the
  2579. ' selected Icon, and maintains it centered within the available
  2580. ' editing space.
  2581. '
  2582. Sub Scrl_Zoom_Change ()
  2583.     
  2584.     ' Check if new value is multiple of 32 pixels.  Magnified Icon must
  2585.     ' always be increased or decreased my muliples of 32 pixels so the
  2586.     ' Win API routine StretchBlt() can be used to magnify the Icon, and
  2587.     ' the result will be an exact enlargement of the original.
  2588.     '
  2589.     If (Scrl_Zoom.Value - 2) Mod Pic_Icons(0).Width Then
  2590.         '
  2591.         ' Scrollbar value is not a multiple of 32, so adjust it so it is.
  2592.         '
  2593.         Scrl_Zoom.Value = Scrl_Zoom.Value - ((Scrl_Zoom.Value - 2) Mod Pic_Icons(0).Width)
  2594.     Else
  2595.         ' Scrollbar value is a multiple of 32 pixels.
  2596.         '
  2597.         ' Hide Edit area while resizing and repainting.  It prevents a
  2598.         ' rather annoying visual affect.
  2599.         '
  2600.         Pic_Edit.Visible = False
  2601.  
  2602.         ' Calculate the new size and position values for the Editing area
  2603.         ' and then reposition and resize both the Editing area and the
  2604.         ' temporary Editing area which is used when magnifying the Icon.
  2605.         '
  2606.         MaxLeft = Scrl_Zoom.Left - (Menu_ViewSelection(MID_ZOOM_SCROLLBAR).Checked * Scrl_Zoom.Width)
  2607.         NewLeft = MaxLeft + (ScaleWidth + Menu_ViewSelection(MID_STATUS_BAR).Checked * Pic_StatusArea.Width - MaxLeft - Scrl_Zoom.Value) \ 2
  2608.         NewTop = (ScaleHeight + Menu_ViewSelection(MID_COLOR_PALETTE).Checked * Pic_ColorPalette.Height - Scrl_Zoom.Value) \ 2
  2609.         Pic_Edit.Move NewLeft, NewTop, Scrl_Zoom.Value, Scrl_Zoom.Value
  2610.         Pic_EditTemp.Move 0, 0, Scrl_Zoom.Value, Scrl_Zoom.Value
  2611.  
  2612.         ' To allow a selection to be maintained if the Zoom scrollbar is scrolled
  2613.         ' while a selection is in progress, the current selection must be scaled
  2614.         ' down to the scale of the actual Icon, the new PixelSize for the Editing
  2615.         ' area must be calculated, and then the selection is Scaled back to the
  2616.         ' new scale of the Editing area.
  2617.         '
  2618.         If Selecting Then Scale_Region True, X1Region, Y1Region, X2Region, Y2Region, False
  2619.         PixelSize = Pic_Edit.ScaleWidth \ 32
  2620.         If Selecting Then Scale_Region False, X1Region, Y1Region, X2Region, Y2Region, False
  2621.  
  2622.         ' Recreate grid if selected and redisplay the Editing area.
  2623.         '
  2624.         If Menu_ViewSelection(MID_GRID).Checked Then Create_Grid
  2625.         Pic_Edit.Visible = True
  2626.  
  2627.         ' Set enable state of Zoom in/out View menu items based on new value
  2628.         ' of the Zoom Scrollbar.
  2629.         '
  2630.         Menu_ViewSelection(MID_ZOOM_IN).Enabled = Scrl_Zoom.Value < Scrl_Zoom.Max
  2631.         Menu_ViewSelection(MID_ZOOM_OUT).Enabled = Scrl_Zoom.Value > Scrl_Zoom.Min
  2632.     End If
  2633.  
  2634. End Sub
  2635.  
  2636. ' In response to Double Clicking the Select tool, or an Edit.Select All
  2637. ' menu operation, this routine is called to perform a selection on the
  2638. ' entire Icon, which is the same as if the Entire icon was selected using
  2639. ' the mouse.
  2640. '
  2641. Sub Select_Entire_Icon ()
  2642.     
  2643.     ' Make the select to the selected tool.  This is neccessary since
  2644.     ' this routine could have been called due to a menu selection, and
  2645.     ' the current tool may not be the Select Tool.
  2646.     '
  2647.     Pic_ToolPalette_MouseDown LEFT_BUTTON, 0, 0, TID_SELECT * 32
  2648.  
  2649.     ' Make all preparations for a selection just as if it was done
  2650.     ' using the mouse.
  2651.     '
  2652.     Prepare_For_Possible_Move
  2653.     Selecting = True
  2654.     Moveable = False
  2655.     Opaque = True
  2656.     Scale_Region False, 0, 0, 32, 32, False
  2657.     Scale_Region True, X1SelectFrom, Y1SelectFrom, X2SelectFrom, Y2SelectFrom, False
  2658.     Draw_Selection_Rectangle
  2659.  
  2660. End Sub
  2661.  
  2662. ' There are two type of grids to choose from when the Grid selection
  2663. ' is active. Line and Dotted grid.  This routine is called in response
  2664. ' to a View.Line Grid or View.Dotted Grid menu operation, to set and
  2665. ' display the selected grid type.  The actual Grid is created in the
  2666. ' Create_Grid procedure.
  2667. '
  2668. Sub Select_Grid_Type (Index)
  2669.     
  2670.     ' Check if selected Grid is already the currently selected grid type,
  2671.     ' since there is no need to redisplay it.
  2672.     '
  2673.     If Not Menu_ViewSelection(Index).Checked Then
  2674.         '
  2675.         ' Toggle Checks on Grid type menu items.
  2676.         '
  2677.         Menu_ViewSelection(MID_LINE_GRID).Checked = Not Menu_ViewSelection(MID_LINE_GRID).Checked
  2678.         Menu_ViewSelection(MID_DOTTED_GRID).Checked = Not Menu_ViewSelection(MID_DOTTED_GRID).Checked
  2679.  
  2680.         ' Create the new Grid and redisplay Icon with new Grid.
  2681.         '
  2682.         Create_Grid
  2683.         Magnify_Icon 0, 0, 31, 31
  2684.     End If
  2685.  
  2686. End Sub
  2687.  
  2688. Sub Select_Tool_MouseUp (X1, Y1, X2, Y2)
  2689.             
  2690.     ' Erase old Selection rectangle
  2691.     '
  2692.     Draw_Selection_Rectangle
  2693.  
  2694.     ' Adjust selection rectangle so it is completely within the
  2695.     ' editing area.
  2696.     '
  2697.     If X1Region > X2Region Then Swap_Values X1Region, X2Region
  2698.     If Y1Region > Y2Region Then Swap_Values Y1Region, Y2Region
  2699.     If X1Region < 0 Then X1Region = 0
  2700.     If Y1Region < 0 Then Y1Region = 0
  2701.     MaxSize = PixelSize * 32
  2702.     If X2Region > MaxSize Then X2Region = MaxSize
  2703.     If Y2Region > MaxSize Then Y2Region = MaxSize
  2704.  
  2705.     If MovingSelection Then
  2706.         '
  2707.         ' The selection is being moved, so all that needs to be done is
  2708.         ' to update the values containing the last location of the
  2709.         ' selection, which are used when the selection is moved.
  2710.         '
  2711.         X1 = LastX1
  2712.         Y1 = LastY1
  2713.         X2 = LastX2
  2714.         Y2 = LastY2
  2715.  
  2716.     ElseIf (X1Region <> X2Region) And (Y1Region <> Y2Region) Then
  2717.         '
  2718.         ' A new selection has been made
  2719.         '
  2720.         Prepare_For_Possible_Move
  2721.         Selecting = True
  2722.         Opaque = True
  2723.  
  2724.         ' Determine if selection can be moved.  The selection cannot be moved
  2725.         ' if it consists of the entire icon.
  2726.         '
  2727.         Moveable = ((X2Region - X1Region) < Pic_Edit.ScaleWidth) Or ((Y2Region - Y1Region) < Pic_Edit.ScaleWidth)
  2728.  
  2729.         Draw_Selection_Rectangle
  2730.         Scale_Region True, X1SelectFrom, Y1SelectFrom, X2SelectFrom, Y2SelectFrom, True
  2731.     End If
  2732.     Scale_Region True, LastX1, LastY1, LastX2, LastY2, True
  2733.  
  2734. End Sub
  2735.  
  2736. ' A move event using the Select tool, can do one of three things,
  2737. ' size the selection rectangle to make the selection, move the
  2738. ' current selection, or copy the current selection to another
  2739. ' location.  This routine either draws the selection rectangle
  2740. ' as the selection is being made or moves/copies the current
  2741. ' selection.
  2742. '
  2743. Sub Select_Tool_Move (Shift As Integer, x As Single, Y As Single)
  2744.  
  2745.     ' Erase old selection rectangle
  2746.     '
  2747.     Draw_Selection_Rectangle
  2748.  
  2749.     If MovingSelection Then
  2750.         '
  2751.         ' Calculate new location of Selection rectangle.
  2752.         '
  2753.         XLastMove = XMoveSelection
  2754.         YLastMove = YMoveSelection
  2755.         Adjust_X_and_Y x, Y, XMoveSelection, YMoveSelection, TO_EDGE
  2756.         X1Region = X1Region + (XMoveSelection - XLastMove)
  2757.         X2Region = X2Region + (XMoveSelection - XLastMove)
  2758.         Y1Region = Y1Region + (YMoveSelection - YLastMove)
  2759.         Y2Region = Y2Region + (YMoveSelection - YLastMove)
  2760.  
  2761.         ' Prevent Selection from being moved of the left or right
  2762.         ' of the editing area
  2763.         '
  2764.         If (X1Region < 0) Or (X2Region > (32 * PixelSize)) Then
  2765.             X1Region = X1Region - (XMoveSelection - XLastMove)
  2766.             X2Region = X2Region - (XMoveSelection - XLastMove)
  2767.         End If
  2768.         
  2769.         ' Prevent Selection from being moved of the top or bottom
  2770.         ' of the editing area
  2771.         '
  2772.         If (Y1Region < 0) Or Y2Region > (32 * PixelSize) Then
  2773.             Y1Region = Y1Region - (YMoveSelection - YLastMove)
  2774.             Y2Region = Y2Region - (YMoveSelection - YLastMove)
  2775.         End If
  2776.     Else
  2777.         ' A selection is being made, so adjust the mouse coordinates
  2778.         ' to the Edge of the pixels so the rectangle is completely
  2779.         ' around the selction.
  2780.         '
  2781.         Adjust_X_and_Y x, Y, X2Region, Y2Region, TO_EDGE
  2782.  
  2783.         ' Make the Selection perfectly square if the Shift key is down
  2784.         '
  2785.         If Shift And SHIFT_MASK Then Make_Region_Square
  2786.     End If
  2787.  
  2788.     ' Draw the new selection recangle
  2789.     '
  2790.     Draw_Selection_Rectangle
  2791.  
  2792. End Sub
  2793.  
  2794. ' When the MousePointer is within the Editing area, the MousePointer
  2795. ' is changed depending on the Tool being used.  This routine is called
  2796. ' from the MouseMove event for the Editing area (Pic_Edit) to change
  2797. ' the MousePointer.
  2798. '
  2799. Sub Set_MousePointer (x As Single, Y As Single)
  2800.     
  2801.     If Selecting And Moveable And (x >= X1Region) And (x <= X2Region) And (Y >= Y1Region) And (Y <= Y2Region) Then
  2802.         '
  2803.         ' A selection is in progress and the selection is moveable,
  2804.         ' and the MousePointer is within the the selection, so the
  2805.         ' MousePointer is changed to a SIZE pointer to indacte
  2806.         ' that the Selection can be moved.
  2807.         '
  2808.         Pic_Edit.MousePointer = SIZE
  2809.     ElseIf (CurrentTool = TID_PAINT) Or (CurrentTool = TID_FILL) Then
  2810.         Pic_Edit.MousePointer = UP_ARROW
  2811.     Else
  2812.         Pic_Edit.MousePointer = CROSSHAIR
  2813.     End If
  2814.  
  2815. End Sub
  2816.  
  2817. ' Since some of the tools can only use Solid colors and not Dithered
  2818. ' colors, it is useful to have the option of displayin only the solid
  2819. ' colors within the ColorPalette.  This routine changes the Color
  2820. ' array to contain only Solid color values then redisplays the
  2821. ' ColorPalette.  There are still 3 rows of colors, but each color
  2822. ' cell in the same column are set to the same solid color.
  2823. '
  2824. Sub Show_Solid_Colors_Only ()
  2825.     
  2826.     ' Set Color array to all solid colors returned from QBColors()
  2827.     '
  2828.     For I = 0 To 15
  2829.         Colors(I) = QBColor(I)
  2830.         Colors(I + 16) = QBColor(I)
  2831.         Colors(I + 32) = QBColor(I)
  2832.     Next
  2833.  
  2834.     ' Redisplay ColorPalettes.
  2835.     '
  2836.     Display_Color_Palette Pic_ColorPalette
  2837.     If ColorPaletteLoaded Then Display_Color_Palette ColorPalette.Pic_ColorPalette
  2838.  
  2839. End Sub
  2840.  
  2841. ' This routine is called in response to an Edit.Undo menu operation.
  2842. ' The Icon displayed in the Undo Icon within the StatusArea is
  2843. ' Copied to the Selected Icon.
  2844. '
  2845. Sub UnDo_Edits ()
  2846.     
  2847.     ' Terminate any Select or Move opteration
  2848.     '
  2849.     Selecting = False
  2850.     MovingSelection = False
  2851.  
  2852.     ' Get Image and Mask of Icon displayed in Undo Icon in StatusArea
  2853.     '
  2854.     Extract_Image_And_Mask Pic_Undo
  2855.  
  2856.     ' Copy Undo Icons Mask and Image to selected icon
  2857.     '
  2858.     Update_Icon Pic_Icons(CurrentIcon)
  2859.  
  2860.     ' Redisplay entire icon
  2861.     '
  2862.     Magnify_Icon 0, 0, 31, 31
  2863.  
  2864. End Sub
  2865.  
  2866. ' When using either the Circle or Filled Circle tool, this routine is called
  2867. ' to verify that the resulting circle from the current Mouse coordinates is
  2868. ' a valid circle, since in some cases the result would be a vertical or
  2869. ' horizontal line which would generate and "Division by Zero" if not checked
  2870. ' for.  If the Circle is valid, this routine calculates and sets the Global
  2871. ' values of XCenter, YCenter, and Raduis for new Circle.
  2872. '
  2873. Function Valid_Circle (X1, Y1, X2, Y2)
  2874.           
  2875.     Xleg = Abs(X2 - X1)
  2876.     If Xleg <> 0 Then
  2877.         Yleg = Abs(Y2 - Y1)
  2878.         Aspect = Abs(Yleg / Xleg)
  2879.         If Xleg > Yleg Then Radius = Xleg / 2 Else Radius = Yleg / 2
  2880.         XCenter = X1 + (X2 - X1) / 2
  2881.         YCenter = Y1 + (Y2 - Y1) / 2
  2882.     End If
  2883.  
  2884.     ' Return value of XLeg at Function value, since if XLeg is non-zero,
  2885.     ' (True) it is a valid circle, and if XLeg is zero (False) it is
  2886.     ' an Invalid circle.
  2887.     '
  2888.     Valid_Circle = Xleg
  2889.  
  2890. End Function
  2891.  
  2892.